-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: render props component for injecting styles (instead of HoC) #11257
Comments
I believe it's a duplicate of #11047. |
We have been documenting a render-prop possible implementation. It's straightforward. |
Oh I see. Hmmm...that's a real bummer that it's a technical difficulty...almost defeats the purpose of using a render-prop implementation... |
The problem of leaving things like this up to the user to implement is
It's such a small amount of code, I think it really makes more sense to put it in this project. |
In any case this really highlights the hackiness of using counters for CSS in JS...maybe there's just no better way because of CSS' own design flaws, but time and time again I get frustrated how brittle counters are. |
I have no strong objection. We started by documenting it to test how people would react. We only had good feedback so far.
What makes you think it's a counter problem? The problem is related to how React calls the hooks. It has to be in the right order. I don't think that it's a hard limitation. It can be worked around. But this requires time. |
Maybe I'm a bit confused. As far as I understand:
In any case having to call To me this side effect of the order in which modules call Here's a thought: if the parent |
@jedwards1211 We have two counters. The first one is used for this purpose and another one is used to guarantee classname uniqueness. I thought you were referring to the second counter as it's the one most people are aware of. The first counter is quite hidden.
Yes, you are right, the counter defines the index of the style in the DOM.
I would also like to benchmark how styled-components is handling the issue. |
Yes, I only knew about it from reading through the |
@oliviertassinari I was thinking about a React hooks API would have the same problem as this with style tag order and overrides. I was thinking, if component A wraps and overrides some classes in component B, A will inject its style element first. But, if I wish there were a DOM/CSSOM API to look up the |
I'm getting tired of HoCs for various reasons, including WebStorm being unable to automatically suggest HoC-wrapped components as imports. It seems like there's a big movement in the community away from HoCs toward render props components.
I made one for
withStyles
here: https://github.com/jcoreio/material-ui-render-props-stylesWould you like for me to add this component to
material-ui
itself?The text was updated successfully, but these errors were encountered: