3 ms·
> So while its true that a state update will rebuild an entire component What if the component does some long computations, for example, calculating a sum of 1
by codedokode 1y ago
> So while its true that a state update will rebuild an entire component
What if the component does some long computations, for example, calculating a sum of 10000 elements of an array? React will do the computation only to find that nothing changed.
- bilalq 1y agoPut that computation in a useMemo and you're good.
- jacobjjacob 1y agoThis example just sounds like it was coded poorly. I would assume that experienced React developers would know to avoid something like this. For inexperienced developers, you don’t need a framework to do something dumb.