Skip to content
React·Advanced·Coding·1 min read

Why split state and dispatch contexts?

Short interview answer

Components that only dispatch events do not need to rerender whenever state changes. Separate contexts express that dependency difference, provided the dispatch value remains stable.

Example

JSX
const StateCtx = createContext(null);const DispatchCtx = createContext(null);// A button that only calls dispatch subscribes to DispatchCtx,// so it never re-renders when state changes.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Context and render performance

Related questions