Patterns

Context provider boundaries

Scope shared values to the descendants that require them; a nested provider can override the outer value.

Formal Syntax & Structure

react syntaxreact
<Context value={outer}><Context value={inner}>{children}</Context></Context>

Working Example

Example Snippetreact
<DensityContext value="compact"><DensityContext value="comfortable"><Room name="Quiet" /></DensityContext></DensityContext>
React Reference