Of course a person can get used to these things, but I question whether it scales to non-tiny teams. There’s a real smell of ye olde dynamic class creation here which React moved away from for very good reasons
Of course a person can get used to these things, but I question whether it scales to non-tiny teams. There’s a real smell of ye olde dynamic class creation here which React moved away from for very good reasons
If you’re talking about the styled() helper, that is something many React style libraries have standardized on from Emotion to Styled Components to Stitches. And actually it’s very important for an optimizing compiler because it limits you down to a statically analyzable subset that focuses just on styles. There’s no magic there either - React Native itself has a similar API with StyleSheet.create, except it won’t optimize even with a future compiler when you start nesting multiple things. That’s where styled() shines.
The exact same conversations were had when JSX came along, react-native-web, etc. We just keep on piling up more and more abstractions.
Some replies: you don’t have to use a special stack you can pass in any component. Theme values and media props are definitely a bit of sugar but hardly magic - they map 1 to 1 to CSS and the other most popular style libraries. And writing them any other way (cross platform) simply doesn’t exist or is much much more complex, so I see them as both necessary and incredibly easy to understand coming from CSS.
The styled function is the whole point! That’s the whole library so that can’t really go away, and it’s just a plain old function there’s 0 magic there.
useMediaPropsActive is a utility function exported for very advanced use cases and it says as much in the docs.
I’ll give you variants, those are borrowed from Stitches and other libraries. They solve several problems elegantly and are also easy to understand. If there’s only one new thing to learn with something as complex as a style library, I’ll take that. Especially with how nice variants are.
No disagreeing that it can be a nice experience using a system like this where things "just work" if you stay within their boundaries; but there is no denying the sheer complexity of it. It is absolutely magic vs say, a bit of HTML + CSS - in which case you can consider what's going on inside the browser as magic.