Question presented to candidate: "React 19 changed the Context syntax. What changed, and does existing code still work?"
What a strong answer should cover:
- You can now render the context object itself as the provider:
<ThemeContext value={x}>instead of<ThemeContext.Provider value={x}>. Context.Providerstill works — this is additive, not a breaking change, and existing code needs no migration.- The implementation detail worth knowing:
Context.Provider === Contextis now true, which is why both syntaxes render identically. Context.Consumeris deprecated in favour ofuseContext, though it still exists. The render-prop consumer predates hooks.- Nothing about the behaviour changed: consumers still all re-render on a value change, the default value still applies only when there is no provider, and there is still no selector mechanism.
- Related React 19 context change:
use(Context)can read a context conditionally, becauseuseallocates no hook slot — unlikeuseContext, which obeys the Rules of Hooks. - Migration: cosmetic. A codemod exists; there is no urgency.
Clarifying questions expected:
- "Are we on React 19 across the whole codebase, or is this a shared library that must support 18?"
Code / implementation expected: Yes — both syntaxes side by side, plus the conditional use(Context) read.