2 ms·
As someone who's worked with React professionally for years, it's honestly shocking how few React developers really understand memoization and when it needs to
by culi 1y ago
As someone who's worked with React professionally for years, it's honestly shocking how few React developers really understand memoization and when it needs to be used
IMO it's the MAIN thing to understand about React—how it renders.
Regardless, now I'm the one with egg on my face since the new compiler promises to eventually remove the need for manual memoization almost entirely. The "almost" still fills me with fear
- adithyassekhar 1y agoIs there a good article or something you could point us younglings to? I get that in react almost everything is reactive by default unlike other frameworks. I tend to add useCallback and memo to everything nowadays.
- moi2388 1y agoThat only works if the inputs don’t change often. If they do, it’s actually a performance hit.
- culi 1y agoThis was one of the best guides out there when it came out. It's from 2021 but I think it still holds up https://alexsidorenko.com/blog/react-render-always-rerenders https://alexsidorenko.com/blog/react-render-always-rerenders It's a set of 6 short and sweet posts that breaks down rendering behavior, memoization, and relevant hooks