React createContext: create a context object
Answer: createContext returns a context object. If you do not have a meaningful default value, specify null. The default value is a last-resort fallback, and it is static and never changes over time. SomeContext.Provider is a legacy way to provide the value before React 19.
Examples
const ThemeContext = createContext(null);
Notes
SomeContext.Consumer is an alternative and rarely used way to read the context value.
Reference list
createContextreturns a context object.nullis what to specify when you have no meaningful default.Provideris the legacy way to provide the value before React 19.
See also
Claims
- id: C1 claim: createContext returns a context object. source: S1 evidence: "createContext returns a context object."
- id: C2 claim: If you have no meaningful default, specify null. source: S2 evidence: "If you don't have any meaningful default value, specify
null."
- id: C3 claim: The default value is static and never changes over time. source: S2 evidence: "It is static and never changes over time."
Sources
- [S1] createContext. React docs. https://react.dev/reference/react/createContext . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] createContext.md. reactjs/react.dev. https://github.com/reactjs/react.dev/blob/main/src/content/reference/react/createContext.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, createContext; reactjs/react.dev, createContext.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, createContext; reactjs/react.dev, createContext.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates.
Cite this
iinventedlight. 2026. "React createContext: create a context object." iinventedlight Library, iil:note:gbv2577q, version of 2026-11-18. https://iinventedlight.com/library/notes/react-createcontext/. License: CC-BY-4.0.
@misc{iil_note_gbv2577q,
author = {{iinventedlight}},
title = {{React createContext: create a context object}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/react-createcontext/},
note = {Permanent ID iil:note:gbv2577q. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- react-createcontext.table.json (table; CC-BY-4.0)
- react-createcontext.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-createcontext.md.