React · Middle · Question 4 of 75
Why doesn't memo help <List items={data} onSelect={() => select(id)} style={{ gap: 8 }} />?
- 1
memodoesn't work with arrow functions in props - ✓Correct answer: The callback and the style object are recreated on every render
- 3
memocan't compare arrays in props
Explanation
An inline function and an object literal are new references on every render, so shallow comparison won't let them through. Stabilize them with useCallback / useMemo, or move constants outside the component. The React Compiler does this automatically.