Skip to content

Commit ae20285

Browse files
committed
docs: clarify recommendation for using <Context> without .Provider (React 19+)
1 parent e9a7cb1 commit ae20285

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/content/reference/react/createContext.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ In older versions of React, use `<SomeContext.Provider>`.
7070

7171
</Note>
7272

73+
> **Recommendation**
74+
> In React 19+, rendering a Context directly (without `.Provider`) is valid.
75+
> However, for most apps we **recommend** using `MyContext.Provider` explicitly because it keeps intent clear, helps avoid accidental default values, and makes future refactors safer.
76+
> Consider the shorthand only when you intentionally rely on the default value in a very small or localized scope.
77+
7378
#### Props {/*provider-props*/}
7479

7580
* `value`: The value that you want to pass to all the components reading this context inside this provider, no matter how deep. The context value can be of any type. A component calling [`useContext(SomeContext)`](/reference/react/useContext) inside of the provider receives the `value` of the innermost corresponding context provider above it.

0 commit comments

Comments
 (0)