5 ms·
Reading the docs, there seems to be a large amount of magical component creation going on that I find difficult to read. A key benefit of React is the simplicit
by shaneos 4y ago
Reading the docs, there seems to be a large amount of magical component creation going on that I find difficult to read. A key benefit of React is the simplicity of a component accepting props and using them in its render function. This library seems to dynamically create a component with a custom configuration language such that it requires a lot of thought to understand what is actually going on. It defines newly available props and their usage differently to other React components, reducing readability considerably.
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
- nwienert 4y agoThere’s nothing at all magical, I’m not sure what you’re thinking is exactly. That’s actually a huge benefit of Tamagui over something like Tailwind for example. You just pass in props and use props just like normal. 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.
- ricardobeat 4y agoIt's always a surprise to see comment like yours - it's obvious that there is a huge gap in how each developer circle sees complexity. In the examples, you need to use the provided Stack component, special props like $gtSm, theme values like $2, the styled() function, variants, and then stuff like useMediaPropsActive() if you want to build your own components. That's plenty of magic. The exact same conversations were had when JSX came along, react-native-web, etc. We just keep on piling up more and more abstractions.
- djur 4y agoWhat is "magic" about any of those? React components are functions, so `styled` would be a function that returns a function. The "special props" are just arguments to those functions. If these are all documented, where's the magic?
- nwienert 4y agoWhat’s funny is I see too much API surface complexity everywhere - a big part of the reason Tamagui exists! For example the entire suite of web specs is insane and never ending, with CSS growing by the day. 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.
- ricardobeat 4y agoI understand where you're coming from, but no, these are not plain functions. This is an optimizing compiler. How long do you think it would take you to read and start understanding how it works: https://github.com/tamagui/tamagui/tree/master/packages https://github.com/tamagui/tamagui/tree/master/packages 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.
- nwienert 4y ago