3 ms·
Maybe I’m a React apologist, but this list of complaints seems mostly self-inflicted. > Form libraries are portly maintained or documented The two-way data bi
by jitl 4y ago
Maybe I’m a React apologist, but this list of complaints seems mostly self-inflicted.
> Form libraries are portly maintained or documented
The two-way data binding in Svelte saves ~4 lines of reusable hook function but doesn’t come close to covering defaults, validation, errors, dependent fields etc - all of that is essential complexity.
Write your own form field hook. The state model for a form is simple - what is a 3rd party library bringing to the table in terms of state management? I have more pain explaining what I want to a 3rd party library than I do writing a bit of code myself to do the same thing. I reach for open-source input components from a vendor for things like credit cards, but manage the state myself.
> useContext and useEffect have annoying dependency tracking; I prefer Solid’s mutable state and automatic dependency tracking.
React’s built-in hooks are positioned as building blocks with clear-cut contracts. Why dump Redux for bare useContext if you prefer Redux’s selectors? Just use Redux. If you like the Solid style of automatic dependency tracking and mutable state, just use Mobx - it’s a mature library for that style that’s been around for 7+ years, and is used in production by products like Linear and Cron.
Overall I agree that function components in React are difficult to get right for developers and a bit too verbose. There’s an onboarding tradeoff to every abstraction you layer over the framework’s APIs, but there’s large advantages too. Do so judiciously to find the sweet spot for your team & scale.
- pier25 4y ago> The two-way data binding in Svelte saves ~4 lines of reusable hook function Based on the RealWorld projects, Svelte saves you around 50% in loc vs React. https://medium.com/dailyjs/a-realworld-comparison-of-front-end-frameworks-2020-4e50655fe4c1 https://medium.com/dailyjs/a-realworld-comparison-of-front-e...
- addicted 4y agoThat’s from 2020 and I’m pretty sure that’s using class components, considering the latest implementations has a separate (using hooks) implementation.
- pier25 4y agoYeah unfortunately the author hasn't kept making these articles. You can see the React+Redux implementation here: https://github.com/khaledosman/react-redux-realworld-example-app https://github.com/khaledosman/react-redux-realworld-example...
- rhodysurf 4y agoTo emphasize the dependency tracking part: being able to control when you want hooks to run is really powerful. Automatic isn’t always better
- rk06 4y ago"Being able to write in assembly is really powerful. Higher level lang like java isn't always better" Sure. but it is better for 99% tasks. And remaining 1% can be achieved via other APIs
- sakagami0 4y agoRight? If anyone likes 2 way binding they should have tried Polymer. 2 way binding is disgustingly complex for large projects and that's why everyone eventually drops it.