Hacker News new | ask | show | jobs
by cjonas 1802 days ago
The whole point of react is to avoid the stateful nightmare created by the latter approach. When given Y, render X.

I'm glad it's not easy to escape the paradigm.

I know there are cases where it's needed but it's rare (at least in my line of work).

2 comments

> The whole point of react is to avoid the stateful nightmare created by the latter approach.

I found this ironic, as I have never in my life had more struggles with state, than when working with react native. Seriously, the amount of times something didn't update, or was updating way too many times, is countless. It's so easy to shoot yourself in the foot. Imperative native programing, almost never have this issue.

You could try angular then, though at some point you're going to run into a similar problem: your zone not becoming stable (mostly a problem when writing tests) because of some external dependency using a setTimeout or setInterval*. But at least it's generally pretty fast at updating and works without shoehorning you into one way of managing state.

Overall I prefer React because I prefer simple composable libraries over frameworks and Angular reminds me too much of programming in Java with its long application boot times and its folders full of ListUpdateCheckerConditionFactoryBeanUnitTest.java's.

*To be fair, in an equivalent React app, at that point you would have had to write a whole lot of shouldComponentUpdate to not tank performance.

Of course! The takeaway is that in the future it would be nice if you could have the best of both worlds by being able to compile some DOM transformations ahead of time and/or have React observe and JIT them so you can bypass React's machinery most of the time while getting to pretend its there. It will feel like a re-render but it's actually just a direct DOM manipulation behind the scenes. That's Svelte in a nutshell.
The future is here and called SolidJS
Solid seems awesome. Though as a Svelte dev, the jsx / React flavored api felt like a regression from the simplicity and readability of Svelte’s template syntax. Have you explored both in depth? I’d be curious to know Solid and its ecosystem compared to Svelte and Sveltekit .