You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/content/blog/index.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: React Blog
6
6
7
7
This blog is the official source for the updates from the React team. Anything important, including release notes or deprecation notices, will be posted here first.
8
8
9
-
You can also follow the [@react.dev](https://bsky.app/profiles/react.js) account on Bluesky, or [@reactjs](https://twitter.com/reactjs) account on Twitter, but you won’t miss anything essential if you only read this blog.
9
+
You can also follow the [@react.dev](https://bsky.app/profile/react.dev) account on Bluesky, or [@reactjs](https://twitter.com/reactjs) account on Twitter, but you won’t miss anything essential if you only read this blog.
Copy file name to clipboardexpand all lines: src/content/learn/passing-data-deeply-with-context.md
+16-16
Original file line number
Diff line number
Diff line change
@@ -468,15 +468,15 @@ import { LevelContext } from './LevelContext.js';
468
468
exportdefaultfunctionSection({ level, children }) {
469
469
return (
470
470
<section className="section">
471
-
<LevelContext.Provider value={level}>
471
+
<LevelContext value={level}>
472
472
{children}
473
-
</LevelContext.Provider>
473
+
</LevelContext>
474
474
</section>
475
475
);
476
476
}
477
477
```
478
478
479
-
This tells React: "if any component inside this `<Section>` asks for `LevelContext`, give them this `level`." The component will use the value of the nearest `<LevelContext.Provider>` in the UI tree above it.
479
+
This tells React: "if any component inside this `<Section>` asks for `LevelContext`, give them this `level`." The component will use the value of the nearest `<LevelContext>` in the UI tree above it.
480
480
481
481
<Sandpack>
482
482
@@ -514,9 +514,9 @@ import { LevelContext } from './LevelContext.js';
514
514
exportdefaultfunctionSection({ level, children }) {
It's the same result as the original code, but you did not need to pass the `level` prop to each `Heading` component! Instead, it "figures out" its heading level by asking the closest `Section` above:
568
568
569
569
1. You pass a `level` prop to the `<Section>`.
570
-
2.`Section` wraps its children into `<LevelContext.Provider value={level}>`.
570
+
2.`Section` wraps its children into `<LevelContext value={level}>`.
571
571
3.`Heading` asks the closest value of `LevelContext` above with `useContext(LevelContext)`.
572
572
573
573
## Using and providing context from the same component {/*using-and-providing-context-from-the-same-component*/}
@@ -595,9 +595,9 @@ export default function Section({ children }) {
595
595
constlevel=useContext(LevelContext);
596
596
return (
597
597
<section className="section">
598
-
<LevelContext.Provider value={level +1}>
598
+
<LevelContext value={level +1}>
599
599
{children}
600
-
</LevelContext.Provider>
600
+
</LevelContext>
601
601
</section>
602
602
);
603
603
}
@@ -643,9 +643,9 @@ export default function Section({ children }) {
@@ -868,7 +868,7 @@ In general, if some information is needed by distant components in different par
868
868
* To pass context:
869
869
1. Create and export it with `exportconstMyContext=createContext(defaultValue)`.
870
870
2. Pass it to the `useContext(MyContext)` Hook to read it in any child component, no matter how deep.
871
-
3. Wrap children into `<MyContext.Provider value={...}>` to provide it from a parent.
871
+
3. Wrap children into `<MyContext value={...}>` to provide it from a parent.
872
872
* Context passes through any components in the middle.
873
873
* Context lets you write components that "adapt to their surroundings".
874
874
* Before you use context, try passing props or passing JSX as `children`.
@@ -1022,7 +1022,7 @@ li {
1022
1022
1023
1023
Remove `imageSize` prop from all the components.
1024
1024
1025
-
Create and export `ImageSizeContext` from `Context.js`. Then wrap the List into `<ImageSizeContext.Provider value={imageSize}>` to pass the value down, and `useContext(ImageSizeContext)` to read it in the `PlaceImage`:
1025
+
Create and export `ImageSizeContext` from `Context.js`. Then wrap the List into `<ImageSizeContext value={imageSize}>` to pass the value down, and `useContext(ImageSizeContext)` to read it in the `PlaceImage`:
1026
1026
1027
1027
<Sandpack>
1028
1028
@@ -1036,7 +1036,7 @@ export default function App() {
1036
1036
const [isLarge, setIsLarge] =useState(false);
1037
1037
constimageSize= isLarge ?150:100;
1038
1038
return (
1039
-
<ImageSizeContext.Provider
1039
+
<ImageSizeContext
1040
1040
value={imageSize}
1041
1041
>
1042
1042
<label>
@@ -1051,7 +1051,7 @@ export default function App() {
Copy file name to clipboardexpand all lines: src/content/reference/react-dom/client/hydrateRoot.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ An app fully built with React will usually not have any calls to `root.unmount`.
99
99
100
100
This is mostly useful if your React root's DOM node (or any of its ancestors) may get removed from the DOM by some other code. For example, imagine a jQuery tab panel that removes inactive tabs from the DOM. If a tab gets removed, everything inside it (including the React roots inside) would get removed from the DOM as well. You need to tell React to "stop" managing the removed root's content by calling `root.unmount`. Otherwise, the components inside the removed root won't clean up and free up resources like subscriptions.
101
101
102
-
Calling `root.unmount` will unmount all the components in the root and "detach" React from the root DOM node, including removing any event handlers or state in the tree.
102
+
Calling `root.unmount` will unmount all the components in the root and "detach" React from the root DOM node, including removing any event handlers or state in the tree.
103
103
104
104
105
105
#### Parameters {/*root-unmount-parameters*/}
@@ -270,7 +270,7 @@ export default function App() {
270
270
271
271
</Sandpack>
272
272
273
-
This only works one level deep, and is intended to be an escape hatch. Don’t overuse it. Unless it’s text content, React still won’t attempt to patch it up, so it may remain inconsistent until future updates.
273
+
This only works one level deep, and is intended to be an escape hatch. Don’t overuse it. React will **not** attempt to patch mismatched text content.
0 commit comments