-
Notifications
You must be signed in to change notification settings - Fork 47
Conversation
I'm interested in details regarding the implementation of |
We’ll share more details when we’re confident this approach isn’t flawed in some fundamental way. We don’t want to say “hey, we now use The issues with specificity are the same ones that pretty much any library that tries to translate inline styles to CSS sheets encounters at some point. I don’t have very good understanding of this but maybe @vjeux (he’s working on it), @ianobermiller (author of Radium), @andreypopp (author of react-stylesheet), or @kof (author of jss) could share some of their expertise. |
I am not sure I am excited about I would rather strive to make react smaller and more focused. As for specificity I can say: don't use more than one class on an element, so you won't get any specificity issues (except of class vs. inline styles but this one is obvious). We can always compose everything one rule needs using js objects and then render it to just one rule and use just one class name. |
There is no plans for StyleSheet.create to be inside of React core at this point fyi. The changes in React I'm considering are better support for inline styles such as RTL support by swapping left and right, browser prefixing, structured way to handle transform attribute instead of a string... Right now what I'm working on is building a StyleSheet.create variant mostly compatible with the one in React Native to output corresponding CSS. This mostly involves fb build infra and doesn't touch React at all |
I am curious if the opposite would also make sense: using things like media queries or animations from CSS in react-native. |
I'll also add: the current experimentation is very tied to existing Facebook infrastructure which means that it is easier for us to move to it as an incremental step while maintaining feature parity and performance with our existing CSS bundling solution. This also means that the code and individual techniques wouldn't be widely applicable even if we were to do the work to extract them at this stage. However, the longer-term goal is to move towards relying on the Facebook CSS infrastructure less and driving everything from JavaScript while having strong confidence that the solution is robust and efficient, at which point we'll look at sharing the work with the community. |
I was a bit puzzled by specificity problems, since I can't think of any css-in-js libraries that have problems with specificity in particular (at least that I'm aware of). In my view, there's a couple things that can make React's handling of inline styles difficult:
Glad to see you're looking at a replacement for Regarding RTL, wouldn't a userland |
RTL isn't as easy as swapping I hope it gives you a sense of what are the challenges, and many of them are very fb-infra specific at this point. |
I'm very interested in keeping tabs on what the React team decides in an official capacity what is the best practice for styles in React. It's obviously been a point of contention for quite some time now. I started with JS styles, but abandoned it for SCSS+BEM, and it works for my project, though is bad for portability and sharing things via npm. |
My idea for fixing "portability" is to keep styles mostly out of components by using a standard for theming, a reference implementation happens right now here |
I'm wondering about debugging inline styles. Thinking specifically in the animation tooling on Chrome DevTools or the simple but handy things such as the toggle element classes. |
Feel free to discuss in this PR!