mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Update context.md (#1420)
This commit is contained in:
@@ -115,7 +115,7 @@ However, sometimes the same data needs to be accessible by many components in th
|
||||
const MyContext = React.createContext(defaultValue);
|
||||
```
|
||||
|
||||
Creates an Context object. When React renders a component that subscribes to this Context object it will read the current context value from the closest matching `Provider` above it in the tree.
|
||||
Creates a Context object. When React renders a component that subscribes to this Context object it will read the current context value from the closest matching `Provider` above it in the tree.
|
||||
|
||||
The `defaultValue` argument is **only** used when a component does not have a matching Provider above it in the tree. This can be helpful for testing components in isolation without wrapping them. Note: passing `undefined` as a Provider value does not cause consuming components to use `defaultValue`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user