4 ms·
Thanks for that insight. I haven't really given this enough of thought until now. For the use case you mentioned, I personally would try to create a styled but
by lewisl9029 11y ago
Thanks for that insight. I haven't really given this enough of thought until now.
For the use case you mentioned, I personally would try to create a styled button component and take custom styles as a prop to extend the default style. However, I think you can also just apply these kinds of globally cascading styles using a regular CSS stylesheet and handle only the state-dependent styles inline if you prefer that approach.
As for features like nth-child, I don't see these being very difficult to implement, because you can easily map/reduce/filter your component tree with React since it's constructed from functional mappings of state data to begin with. nth-child would be as simple as applying/extending a style when (index + 1) % n === 0, for instance.
Descendant selectors, I'm honestly not too sure about.
- purplerabbit 11y ago+1 for (s)css-ing as normal and adding state-dependent styles as necessary. I've yet to see a better approach.