From efcd91eda347dba15b3d4e83caabfd2a16119ee1 Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Mon, 22 Apr 2024 11:08:55 -0400 Subject: [PATCH] Add as a provider --- src/content/blog/2024/04/01/react-19.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/content/blog/2024/04/01/react-19.md b/src/content/blog/2024/04/01/react-19.md index f4701f9ce..1ee546134 100644 --- a/src/content/blog/2024/04/01/react-19.md +++ b/src/content/blog/2024/04/01/react-19.md @@ -781,6 +781,27 @@ Todo: This requires the new transform, correct? For more information, see [Manipulating the DOM with refs](/learn/manipulating-the-dom-with-refs) +### `` as a provider {/*context-as-a-provider*/} + +In React 19, you can render `` as a provider instead of ``: + + +```js {5,7} +const ThemeContext = createContext(''); + +function App({children}) { + return ( + + {children} + + ); +} +``` + +In future versions we will deprecate ``. + +For more, see [`createContext`](/reference/react/createContext). + ### `useDeferredValue` inital value {/*use-deferred-value-initial-value*/} We've added an `initalValue` option to `useDeferredValue`: @@ -801,7 +822,6 @@ When initialValue is provided, React will return i For more, see [`useDeferredValue`](/reference/react/useDeferredValue). - ### Support for Document Metadata {/*support-for-metadata-tags*/} In HTML, document metadata tags like `` and `<meta>` are reserved for placement in the `<head>` section of the document. In React, it's often convenient these elements deeper in the tree where the data for those tags is available. In the past, these elements would need to be inserted manually in an effect, or by libraries like [`react-helmet`](github.com/nfl/react-helmet). @@ -1002,8 +1022,6 @@ TODO More improvements? - Strict Mode improvements -- useDeferredValue initialValue -- Context.Provider is replaced with Context - Refs can now return a cleanup function. (TODO: docs)