QuizNot attempted
Splitting state and actions contexts
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Every consumer re-renders when the context value changes; split into a State context and a memoized Actions context
- Context has no selectors: when the provided object changes, every consumer re-renders, even one that only reads
setValue. - Split into a State context and an Actions context whose value is memoized (setters are stable), so action-only consumers never re-render.
- **Not 'buttons always re-render
- useCallback':** the cause is the context value, and useCallback on the button changes nothing.
- Not 'setValue changes identity':
useStatesetters are stable. - Not 'only the Provider re-renders': consumers re-render directly on value changes.