React is fast by default, but performance issues can appear in large or complex applications. Optimizing React improves speed, responsiveness, and user experience.
Unnecessary re-renders
Large component trees
Expensive calculations on every render
Inefficient state management
Large bundle sizes
React.memoMemoizes a component and prevents re-render if props don’t change.
useCallbackMemoizes functions to avoid re-creation on every render.
Useful when passing callbacks to memoized components.
useMemoMemoizes expensive calculations.
Load components only when needed.
❌ Causes re-renders:
✅ Better:
Use stable, unique keys
Avoid array index as key
Render only visible items.
Libraries:
react-window
react-virtualized
Keep state local when possible
Avoid unnecessary global state
Split large states into smaller pieces
Reduce frequent updates (e.g., search input).
Minified
Optimized
Faster load times
Context causes re-render of all consumers
Split contexts if needed
Tools:
React DevTools Profiler
Chrome Performance tab
Lighthouse
Memoize components and functions
Lazy load routes and components
Use proper keys
Minimize state and re-renders
Measure before optimizing
Optimize only when needed
Focus on re-render reduction
Use memoization wisely
Measure performance regularly
Take quizzes related to this topic and see where you stand!
Start Quiz Now