React Performance: Why Colocating State Beats useMemo for Most Apps
A developer who has profiled dozens of React applications identifies recurring performance mistakes and the patterns that reliably fix them. The most impactful fix is colocating state — keeping state in the component that actually needs it rather than lifting it unnecessarily to a parent, which eliminates unnecessary re-renders at zero cost. For values that change frequently but do not need to trigger re-renders, such as mouse positions in canvas animations, using a ref instead of state prevents React from scheduling redundant updates. React.memo is recommended for expensive component subtrees, with useMemo and useCallback reserved for stabilizing props only after profiling confirms a bottleneck. For lists exceeding roughly 100 rows, virtualizing the DOM with a library like TanStack Virtual can reduce rendered nodes from thousands to around 20 regardless of list size.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in