APIs

Context.Consumer

Legacy render-function interface for reading context; prefer useContext for new function components.

Formal Syntax & Structure

react syntaxreact
<Context.Consumer>{value => /* element */}</Context.Consumer>

Working Example

Example Snippetreact
<UnitContext.Consumer>{unit => <p>{unit}</p>}</UnitContext.Consumer>
React Reference