4 ms·
> Frameworks should be built up to preserve the structure that the language provide. > React does this the best. Considering idiomatic React basically necessit
by toastercat 5y ago
> Frameworks should be built up to preserve the structure that the language provide.
> React does this the best.
Considering idiomatic React basically necessitates JSX, no, React does not do it the best. Frameworks that embrace things like hyperscript and regular .js files over unnecessary aesthetics and goofy file extensions like .jsx do this better than React (Preact, Mithril, Hyperapp). Even hooks are weird and magical to JS veterans -- most people hopping into React are essentially told "just accept this, it works, and you don't have to understand how".
- bern4444 5y agoI've never really understood the hooks are complicated line. Maybe it's the understanding that they integrate with React's event system (which I think is powered by something like rxjs/observables), but hooks make the most sense once you start implementing custom hooks which are incredibly easy to write and reuse. Need a hook for undoable (and re-doable) state? It can be implemented in ~30 lines and then used anywhere in your application. Need a hook to manage data from an API across your application, a custom hook makes this trivial especially if you need to connect it with your global state management (like redux/context/etc). JSX is nothing special and it's possible (and trivial) to set up your component files to use a .js extension. The only thing JSX does is let you write components with an HTML like syntax instead of with a bunch of function calls. I find this extremely ergonomic. Bad React is when the two ideas - view and component logic - are mixed too much. That's the point at which components need to be broken down further to avoid bloat or a custom hook is needed to handle data.
- toastercat 5y agoI feel like you're speaking completely past me, because I never said using hooks were complicated. On the surface, they simplify quite a whole lot to the point where complete beginners to JavaScript can grasp them and be productive quickly.