React · Middle · Question 3 of 75
What does React.memo(Component) do?
- ✓Correct answer: Skips rendering if props are shallowly equal to the previous ones
- 2Caches the component's DOM between SPA page transitions
- 3Memoizes the results of all computations inside the component
Explanation
memo compares each prop with Object.is. If all are equal, the previous render result is reused. Changes to its own state and context still trigger a render. You can pass a custom comparison function as the second argument.