Intermediate React Interview QuestionsIntermediateComparison
React · Question 55
What is the difference between memo, useMemo, and useCallback?
Direct answer
memo memoizes a component against unchanged props, useMemo caches a calculated value, and useCallback caches a function definition.
| API | What it caches | Typical reason |
|---|---|---|
| memo | Component render result based on props | Skip parent-driven child renders |
| useMemo | Result of a calculation | Skip expensive recalculation or stabilize a value |
| useCallback | Function definition | Stabilize callback identity for a consumer |
All three are performance tools. Code should remain correct if the optimization is removed.