Skip to content

Commit c95de8b

Browse files
authored
Clarify defaultValue usage (#868)
Fixes #867
1 parent c434be8 commit c95de8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/docs/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const {Provider, Consumer} = React.createContext(defaultValue);
4848

4949
Creates a `{ Provider, Consumer }` pair. When React renders a context `Consumer`, it will read the current context value from the closest matching `Provider` above it in the tree.
5050

51-
The `defaultValue` argument is used when you render a Consumer without a matching Provider above it in the tree. This can be helpful for testing components in isolation without wrapping them.
51+
The `defaultValue` argument is **only** used by a Consumer when it 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 Consumers to use `defaultValue`.
5252

5353
### `Provider`
5454

0 commit comments

Comments
 (0)