Giter VIP home page Giter VIP logo

Comments (9)

robinweser avatar robinweser commented on June 4, 2024 1

@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.

steida avatar steida commented on June 4, 2024

Why not leverage componentWillMount and componentWillUnmount methods?

from fela.

robinweser avatar robinweser commented on June 4, 2024

@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.

steida avatar steida commented on June 4, 2024

I see, can you explain please when exactly to stylesheets grows? For example, wrong usage in animation?

from fela.

steida avatar steida commented on June 4, 2024

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.

robinweser avatar robinweser commented on June 4, 2024

I guess we need to check if this is performant at all, compared to just keep the styles.

from fela.

steida avatar steida commented on June 4, 2024

I think it's the right behaviour anyway. When any component is removed, its style should be removed as well.

from fela.

robinweser avatar robinweser commented on June 4, 2024

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.

johanneslumpe avatar johanneslumpe commented on June 4, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.