docs: clarify recommendation for using <Context> without .Provider (React 19+)#7910
docs: clarify recommendation for using <Context> without .Provider (React 19+)#7910PWuttam wants to merge 1 commit intoreactjs:mainfrom
Conversation
|
Hi @PWuttam! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
| > **Recommendation** | ||
| > In React 19+, rendering a Context directly (without `.Provider`) is valid. | ||
| > 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. | ||
| > Consider the shorthand only when you intentionally rely on the default value in a very small or localized scope. |
There was a problem hiding this comment.
No, this is not our recommendation. <Context.Provider> is legacy, use <Context>. In the React 19 blog post we said in the future we'll deprecate Context.Provider - as we eventually do with all legacy APIs.

Clarifies documentation in createContext.md to explain that rendering a Context directly (without .Provider) is valid in React 19+.
Also adds a recommendation to use MyContext.Provider in most cases for clarity, to avoid accidental default values, and to make refactors safer.
Fixes #7907