React.memo Purpose
Question
What does React.memo do?
Hint
React.memo does a shallow prop comparison by default.
Explanation
React.memo(Component) wraps a component to prevent re-renders when its props have not changed (shallow comparison). This is useful for components that receive stable props but re-render because their parent re-renders. For custom comparison, pass a second argument: React.memo(Component, areEqual). Use memo for components that render often with the same props, especially list items. Combined with useMemo/useCallback for object/function props to prevent unnecessary re-renders.
Related Resources
Related Lessons
- Memoization
Learn memoization.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.