Why does my React component re-render too often?
Common causes of excessive re-renders
React re-renders a component when its state or props change, or when its parent re-renders. If a parent re-renders, all children re-render by default, even if their props haven't changed. Passing new object or array literals as props each render creates new references, triggering re-renders. Inline functions also create new references. Context updates cause all consumers to re-render.
Also, if you update state in a way that doesn't change the value (e.g., setting the same value), React may still re-render once. Using the state updater function incorrectly can cause extra renders.
How to diagnose and fix
Use React DevTools Profiler to identify which components re-render and why. Wrap components in React.memo to prevent re-renders when props are shallowly equal. Use useCallback to memoize functions and useMemo to memoize expensive computations or object references. Ensure dependency arrays are correct. For context, split contexts or use selectors.
Avoid defining components inside other components, as this creates new component types on each render. Lift state up only when necessary, and consider state management libraries for complex cases.
- Use React.memo for pure components
- Memoize callbacks with useCallback
- Memoize values with useMemo
- Avoid inline object/array props
- Split contexts to reduce consumers
- Use DevTools Profiler to find culprits
Common mistakes
- Assuming all re-renders are bad—some are necessary and cheap.
- Overusing useMemo and useCallback, which can add complexity and overhead.
- Forgetting that React.memo only does a shallow comparison; deep equality requires custom comparison.

Related questions
- How do I choose between React, Vue, and Angular for a new project?
- What is the difference between a framework and a library in JavaScript?
- Is React still the best choice for building a large web app?
- Should I learn React or Vue first as a beginner?
- Can I use React and Vue together in the same project?
- Should I use Svelte instead of React for a new project?