createContext
createContext is a library API function that creates a context object for providing and reading shared values among components.
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 →
Also covered in
- React in Depth
- Web Component Development with Modern Libraries and ToolingIn early access (MEAP)
What to know first
- component hierarchyA component hierarchy is a tree-structured organization of components connected through parent-child relationships.
Related concepts
- React contextproduces · React context is a mechanism for making values available to descendant components without explicitly passing them through intermediate components.
- context objectproduces · A context object is a structured value that carries information or state for access by components or operations within a defined scope.
- type argumentconfigured by · A type argument is a type supplied for a type parameter to specify or constrain the types accepted by a generic construct.
- use-context-selectorconfigured by · use-context-selector is a React library for consuming selected values from context while limiting updates to consumers whose selected values change.
- default valueconfigures · A default value is a predefined value automatically applied when no explicit value is supplied or specified.
Questions about createContext
What is createContext?
createContext is a library API function that creates a context object for providing and reading shared values among components.
Which Manning books explain createContext?
React Quickly, Second Edition and React Hooks in Action: With Suspense and Concurrent Mode.
What should I know before learning createContext?
Manning books that teach createContext usually introduce component hierarchy first.
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.

