Comments (9)
@steida Yeah exactly. e.g.
const rule = props => ({
position: 'absolute',
// assuming it passes the scrollTop on every 'scroll' event
top: props.scrollTop
})
Another one would be: Having sth. like a parallax page with 10000 elements and a lot of dynamic rendering on run-time. You might get thousands of classes though only 100 are used at the same time.
This is nothing that only happens to Fela, but is even more problematic with static CSS files.
We might want to have some options for the user to decide when to terminate styles, but yet I do not see any advantage yet. :P
from fela.
Why not leverage componentWillMount and componentWillUnmount methods?
from fela.
@steida First of all, this is a general "issue" (not really an issue though) so we're not only talking about the React world.
Also we would have to track the number of rendered components to safely remove classes only if the last instance gets unmount. A component that shares the same Fela rule might be rendered multiple times. But if you remove the class (especially the static one) if the first gets unmount, the others would loose there style.
It might not be a problem to track instances at all, but I don't see any advantage as well. I had no problem with growing stylesheets in any of my projects.
from fela.
I see, can you explain please when exactly to stylesheets grows? For example, wrong usage in animation?
from fela.
Also we would have to track the number of rendered components to safely remove classes only if the last instance gets unmount.
That's what we need to do I suppose.
from fela.
I guess we need to check if this is performant at all, compared to just keep the styles.
from fela.
I think it's the right behaviour anyway. When any component is removed, its style should be removed as well.
from fela.
You cannot treat CSS classes same as components. As every component instance is 1-1 relation while CSS classes are 1-many. So we can only safely remove the class if the last component instance using that class is unmount. (Though I guess that's what you meant anyways)
from fela.
@rofrischmann I assume that's what @steida meant - reference counting. If we did that, how would we account for dynamic rules? We would somehow have to tag them with the name of the component they are used for in order to be able to remove them later?!
from fela.
Related Issues (20)
- react-fela providers only accept single element children HOT 2
- Use fela with ReactDOM.createPortal on a different window HOT 1
- fela-plugin-responsive-value doesn’t handle nested objects
- Fela doesn’t hydrate CSS custom properties HOT 1
- fela-plugin-multiple-selectors doesn’t extend styles
- renderStatic doesn’t handle nested objects
- Document targetDocument
- renderToNodeList not exported in react-fela/index.d.ts HOT 1
- Typescript plugin doesn't extend style definition HOT 5
- Native ESM support HOT 5
- renderStatic not applying some plugins HOT 6
- Missing changelog for 11.5.x & 11.6.x HOT 2
- Rehydration of `&` selectors HOT 10
- Rules are mixing between components when we switch between pages. HOT 1
- Typescript interface for renderer configuration (IConfig) misses some options HOT 2
- Transform key as array ignored HOT 5
- [Feature] Add bindings for solid-js HOT 1
- Fail to set backgroundImage fallback value HOT 3
- Bug: no fela styles on saved page HOT 1
- react-native: no style export in useFela hook HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fela.