4 ms·
The big part that seems to thoroughly confuses developers new to React is the difference between rendering and reconciliation. This is not particularly difficul
by fabian2k 4y ago
The big part that seems to thoroughly confuses developers new to React is the difference between rendering and reconciliation. This is not particularly difficult to understand, but the original emphasis on the virtual DOM seems to lead to a misunderstanding on how React works. The vDOM plays a role only after rendering happened, so all that diffing stuff doesn't have anything to do with rendering. To me that seems like one of the primary causes of developers being surprised that React rerenders more than they expect.
I like the explanation on what triggers rendering in this post. Props and state are usually used in the explanation for this part, but props actually only matter if you want to use React.Memo. And the one part every React developer should know is that in the absence of React.Memo all children will rerender if any state changes.
- DanielHB 4y agoyeah, this is key. What you should be REALLY avoiding is unnecessary DOM updates, rerenders have a cost too, but marginal compared to DOM updates and even then you mostly don't need to care either except in extreme situations (like useCallback is not really necessary most of the time0