React · Senior · Question 47 of 75
Why can React.memo with a custom comparison function be dangerous?
- ✓Correct answer: If not all props are compared, the component shows stale data or callbacks
- 2A custom comparison function is forbidden in the production build
- 3The function runs on the server and slows down SSR
Explanation
arePropsEqual must account for all props, including functions: if you ignore a callback, the component calls its old version with a "frozen" closure. Deep comparison of large data can cost more than the render itself. Stabilizing props is usually the better choice.