Category: Next.js, React and TypeScript

React Context: all rows render after changing one field

Read this guide in Polish

In CRM, changing a single item of the list re-renders a large number of independent components. The context value object can have a new identity on each provider render, even if logical data has not changed.

How to identify the source of the problem

In React DevTools Profiler find Context component.Provider and elements responsive to update. Check if value={{...}} and transmitted callbacks are created again in each render.

Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.

Repair steps

Divide contexts according to independent data types and stabilize the values and functions you really need. For large lists consider state selectors or separate store instead of one context containing all records.

How to Test Solution

The profiler shows a smaller number of unnecessary renders while maintaining correct updates.

Security and restrictions

Do not memoize the entire application with accidental useMemo without measuring actual bottlenecks.