Skip to content

Conversation

@PWuttam
Copy link

@PWuttam PWuttam commented Aug 10, 2025

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

@meta-cla
Copy link

meta-cla bot commented Aug 10, 2025

Hi @PWuttam!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions
Copy link

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@meta-cla meta-cla bot added the CLA Signed label Aug 10, 2025
> **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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rickhanlonii
Copy link
Member

The text right above this has this correct information:

Screenshot 2025-09-02 at 1 50 50 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion]: Clarify recommendation status for using <Context> without .Provider

2 participants