Comment by papa0101
1 day ago
React and its ecosystem is a pile of garbage perpetuated by industry inertia. UseState, useMemo, useThisAndThat where you have to guess whether that dependency will cause a re-render? Or 20 different routers, state managers, query builders? I'm not even talking about html-in-ts with `!!a && (<div>...</div>)` A stodgy, bloated, overhyped and misused monstrosity, that's what React is.
useMemo is definitely a scourge on my existence. Doesn't help that a bunch of people write articles like "don't bother with it!!" when memoisation results can cause actual real bugs when integrating with a third party lib.
Unmounting and then remounting the same component is actually a bad thing when you lose your component state in the process. And when you have enough useEffect's in your system that's exactly what happens unless you're liberally sprinkling useMemo
React is opinionated. The whole point of the library is having UI updates being driven by state mutation. When I hear complain about the hooks, I ask about what is the state, and where do mutations occur, and usually, I get blank stares in returns.
It's all about the state. `useState` is the starting point (adding new items to the state set), `useEffect` for tying the UI to external systems, `useMemo` for state transformation, `useRef` for storing stuff outside of the state you want to react to,... Then you use custom hooks to make the code modular, stuff like usePost, useProfile, useCommentUpvote,... (HN domain)
If you design your state well, the application, at least the UI layer, becomes easy to code and maintain.