React useContext: read a context value from a provider
Answer: useContext returns the context value for the calling component. The returned value is always up-to-date. The matching Provider needs to be above the component that calls useContext().
Examples
const value = useContext(ThemeContext);
Notes
React re-renders components that read some context when it changes. Values are compared with Object.is. memo does not stop children from receiving a fresh context value.
Reference list
useContextreturns the context value for the calling component.Providerneeds to be above the component that calls useContext.Object.isis how the previous and next values are compared.
See also
Claims
- id: C1 claim: useContext returns the context value for the calling component. source: S1 evidence: "useContext returns the context value for the calling component"
- id: C2 claim: The returned value is always up-to-date. source: S1 evidence: "The returned value is always up-to-date."
- id: C3 claim: The Provider needs to be above the component that calls useContext. source: S2 evidence: "the component doing the
useContext()call"
Sources
- [S1] useContext. React docs. https://react.dev/reference/react/useContext . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] useContext.md. reactjs/react.dev. https://github.com/reactjs/react.dev/blob/main/src/content/reference/react/useContext.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, useContext; reactjs/react.dev, useContext.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, useContext; reactjs/react.dev, useContext.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 useContext: read a context value from a provider." iinventedlight Library, iil:note:eap6y282, version of 2026-11-18. https://iinventedlight.com/library/notes/react-usecontext/. License: CC-BY-4.0.
@misc{iil_note_eap6y282,
author = {{iinventedlight}},
title = {{React useContext: read a context value from a provider}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/react-usecontext/},
note = {Permanent ID iil:note:eap6y282. 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-usecontext.table.json (table; CC-BY-4.0)
- react-usecontext.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-usecontext.md.