diff --git a/src/content/learn/managing-state.md b/src/content/learn/managing-state.md index f2f02c64b9d..ef7b76e04c2 100644 --- a/src/content/learn/managing-state.md +++ b/src/content/learn/managing-state.md @@ -837,9 +837,7 @@ export function TasksProvider({ children }) { return ( - + {children} diff --git a/src/content/learn/scaling-up-with-reducer-and-context.md b/src/content/learn/scaling-up-with-reducer-and-context.md index e193333b9b2..91fb6803fb1 100644 --- a/src/content/learn/scaling-up-with-reducer-and-context.md +++ b/src/content/learn/scaling-up-with-reducer-and-context.md @@ -1363,4 +1363,3 @@ As your app grows, you may have many context-reducer pairs like this. This is a - You can have many context-reducer pairs like this in your app. - diff --git a/src/content/reference/react/createContext.md b/src/content/reference/react/createContext.md index 5b2cc0eb227..2161fa63c69 100644 --- a/src/content/reference/react/createContext.md +++ b/src/content/reference/react/createContext.md @@ -46,7 +46,7 @@ const ThemeContext = createContext('light'); --- -### `SomeContext` {/*provider*/} +### `SomeContext` Provider {/*provider*/} Wrap your components into a context provider to specify the value of this context for all components inside: @@ -62,6 +62,14 @@ function App() { } ``` + + +Starting in React 19, you can render `` as a provider. + +In older versions of React, use ``. + + + #### Props {/*provider-props*/} * `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. @@ -215,4 +223,3 @@ const ThemeContext = createContext('light'); This value never changes. React only uses this value as a fallback if it can't find a matching provider above. To make context change over time, [add state and wrap components in a context provider.](/reference/react/useContext#updating-data-passed-via-context) - diff --git a/src/content/reference/react/legacy.md b/src/content/reference/react/legacy.md index b22a9c97eeb..f4e3ebe289f 100644 --- a/src/content/reference/react/legacy.md +++ b/src/content/reference/react/legacy.md @@ -30,6 +30,6 @@ These APIs were removed in React 19: * [`createFactory`](https://18.react.dev/reference/react/createFactory): use JSX instead. * Class Components: [`static contextTypes`](https://18.react.dev//reference/react/Component#static-contexttypes): use [`static contextType`](#static-contexttype) instead. * Class Components: [`static childContextTypes`](https://18.react.dev//reference/react/Component#static-childcontexttypes): use [`static contextType`](#static-contexttype) instead. -* Class Components: [`static getChildContext`](https://18.react.dev//reference/react/Component#getchildcontext): use [`Context.Provider`](/reference/react/createContext#provider) instead. +* Class Components: [`static getChildContext`](https://18.react.dev//reference/react/Component#getchildcontext): use [`Context`](/reference/react/createContext#provider) instead. * Class Components: [`static propTypes`](https://18.react.dev//reference/react/Component#static-proptypes): use a type system like [TypeScript](https://www.typescriptlang.org/) instead. * Class Components: [`this.refs`](https://18.react.dev//reference/react/Component#refs): use [`createRef`](/reference/react/createRef) instead.