5 ms·
I would have to respectfully disagree. React Hooks was probably the last "big" update to React and it totally changed how you build an application. The issue wi
by _fat_santa 2y ago
I would have to respectfully disagree. React Hooks was probably the last "big" update to React and it totally changed how you build an application. The issue with hooks is you had hooks like useEffect that has very clear footguns that most seasoned developers knew but new developers would step on over and over and you also had optimization strategies with useMemo that weren't well known unless you've been around react for a while. Thing is with both of these is they can be automated with a compiler rather than having devs optimize it manually. My code has a ton of useMemo's and those micro optimizations and I estimate I can eliminate about 10k LOC assuming the react compiler does what it's advertised to do.
- PaulHoule 2y agoContrary to what a lot of people say, useMemo is more than a performance optimization. If React decides to create a new instance of a component because it thinks a parameter change happened all the state in that component can get dumped which can have effects like a bunch of selections in a combo box disappearing.
- SebastianKra 2y agoThis does not happen. If you're losing state, it's always either because A: the component is replaced with another, B: the component is removed, C: you have given this component a key and changed it. From your example, I think you've assigned bad keys, or forgot to assign keys (for which the linter will scream at you)