Skip to content

Commit 05bd08d

Browse files
authored
fix conflict
1 parent 9e6704e commit 05bd08d

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

src/content/blog/index.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@ title: React Blog
44

55
<Intro>
66

7-
<<<<<<< HEAD
87
这个博客是 React 团队更新的官方来源。任何重要的内容,包括发布说明或弃用通知,都会首先在这里发布。
9-
=======
10-
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.
118

12-
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.
13-
>>>>>>> 5f09d9f4467871955d794aa5fbc7bf3c4e7a5f4f
14-
15-
你也可以在 Bluesky 上关注 [@react.dev](https://bsky.app/profiles/react.js) 的账号,Twitter 的 [@reactjs](https://twitter.com/reactjs) 账号,但如果你只阅读这个博客,你也不会错过任何重要的内容。
9+
你也可以在 Bluesky 上关注 [@react.dev](https://bsky.app/profile/react.dev),或者在 Twitter 上关注 [@reactjs](https://twitter.com/reactjs)。不过只要你阅读这个博客,就不会错过任何重要内容。
1610
</Intro>
1711

1812
<div className="sm:-mx-5 flex flex-col gap-5 mt-12">

src/content/learn/passing-data-deeply-with-context.md

+4-29
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,7 @@ export default function Section({ level, children }) {
479479
}
480480
```
481481

482-
<<<<<<< HEAD
483-
这告诉 React:“如果在 `<Section>` 组件中的任何子组件请求 `LevelContext`,给他们这个 `level`。”组件会使用 UI 树中在它上层最近的那个 `<LevelContext.Provider>` 传递过来的值。
484-
=======
485-
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.
486-
>>>>>>> 5f09d9f4467871955d794aa5fbc7bf3c4e7a5f4f
482+
这告诉 React:“如果在 `<Section>` 组件中的任何子组件请求 `LevelContext`,给他们这个 `level`。”组件会使用 UI 树中在它上层最近的那个 `<LevelContext>` 传递过来的值。
487483

488484
<Sandpack>
489485

@@ -573,15 +569,9 @@ export const LevelContext = createContext(1);
573569

574570
这与原始代码的运行结果相同,但是你不需要向每个 `Heading` 组件传递 `level` 参数了!取而代之的是,它通过访问上层最近的 `Section` 来“断定”它的标题级别:
575571

576-
<<<<<<< HEAD
577572
1. 你将一个 `level` 参数传递给 `<Section>`
578-
2. `Section` 把它的子元素包在 `<LevelContext.Provider value={level}>` 里面。
573+
2. `Section` 把它的子元素包在 `<LevelContext value={level}>` 里面。
579574
3. `Heading` 使用 `useContext(LevelContext)` 访问上层最近的 `LevelContext` 提供的值。
580-
=======
581-
1. You pass a `level` prop to the `<Section>`.
582-
2. `Section` wraps its children into `<LevelContext value={level}>`.
583-
3. `Heading` asks the closest value of `LevelContext` above with `useContext(LevelContext)`.
584-
>>>>>>> 5f09d9f4467871955d794aa5fbc7bf3c4e7a5f4f
585575

586576
## 在相同的组件中使用并提供 context {/*using-and-providing-context-from-the-same-component*/}
587577

@@ -878,25 +868,14 @@ Context 不局限于静态值。如果你在下一次渲染时传递不同的值
878868
879869
<Recap>
880870
881-
<<<<<<< HEAD
882871
* Context 使组件向其下方的整个树提供信息。
883872
* 传递 Context 的方法:
884873
1. 通过 `export const MyContext = createContext(defaultValue)` 创建并导出 context。
885874
2. 在无论层级多深的任何子组件中,把 context 传递给 `useContext(MyContext)` Hook 来读取它。
886-
3. 在父组件中把 children 包在 `<MyContext.Provider value={...}>` 中来提供 context。
875+
3. 在父组件中把 children 包在 `<MyContext value={...}>` 中来提供 context。
887876
* Context 会穿过中间的任何组件。
888877
* Context 可以让你写出 “较为通用” 的组件。
889878
* 在使用 context 之前,先试试传递 props 或者将 JSX 作为 `children` 传递。
890-
=======
891-
* Context lets a component provide some information to the entire tree below it.
892-
* To pass context:
893-
1. Create and export it with `export const MyContext = createContext(defaultValue)`.
894-
2. Pass it to the `useContext(MyContext)` Hook to read it in any child component, no matter how deep.
895-
3. Wrap children into `<MyContext value={...}>` to provide it from a parent.
896-
* Context passes through any components in the middle.
897-
* Context lets you write components that "adapt to their surroundings".
898-
* Before you use context, try passing props or passing JSX as `children`.
899-
>>>>>>> 5f09d9f4467871955d794aa5fbc7bf3c4e7a5f4f
900879
901880
</Recap>
902881
@@ -1047,11 +1026,7 @@ li {
10471026
10481027
移除掉所有组件中的 `imageSize` 参数。
10491028
1050-
<<<<<<< HEAD
1051-
`Context.js` 中创建并导出 `ImageSizeContext`。然后用 `<ImageSizeContext.Provider value={imageSize}>` 包裹住整个列表来向下传递值,最后在 `PlaceImage` 中使用 `useContext(ImageSizeContext)` 来读取它。
1052-
=======
1053-
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`:
1054-
>>>>>>> 5f09d9f4467871955d794aa5fbc7bf3c4e7a5f4f
1029+
`Context.js` 中创建并导出 `ImageSizeContext`。然后用 `<ImageSizeContext value={imageSize}>` 包裹住整个列表来向下传递值,最后在 `PlaceImage` 中使用 `useContext(ImageSizeContext)` 来读取它。
10551030
10561031
<Sandpack>
10571032

0 commit comments

Comments
 (0)