liveBook · Manning

createContext

createContext is a library API function that creates a context object for providing and reading shared values among components.

How 2 Manning books explain it

React Quickly, Second Edition

createContext is a React API function that creates a context object for supplying and reading a shared value.

How it is used
Defines shared React values that avoid passing props through unrelated components in a descendant tree.
How deep it goes
Explains the function, default value, provider, hook, and render-prop consumer, but defers deeper implementation internals.
Examples
Demonstrates a dashboard name, menu links, and button border widths supplied through separate context providers.
What you can do after
Build it from scratch by defining a context, providing a value, and reading it with useContext.

Read how React Quickly, Second Edition explains createContext →

React Hooks in Action: With Suspense and Concurrent Mode

createContext is a React API function that creates a context object for sharing a value with descendant components.

How it is used
Creates a shared current-user channel for components in a bookings application.
How deep it goes
Defines context creation and Provider placement, while deferring deeper implementation internals.
Examples
Uses UserContext, App, UserPicker, BookingDetails, and a current-user edit-button scenario.
What you can do after
Build shared React state by creating a context, providing its value, and reading it in descendants.

Read how React Hooks in Action: With Suspense and Concurrent Mode explains createContext →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.