Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
awxiaoxian2020 committed Oct 2, 2023
1 parent 082960f commit 82075f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/content/learn/referencing-values-with-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,7 @@ console.log(ref.current); // 5

## ref 和 DOM {/*refs-and-the-dom*/}

<<<<<<< HEAD
你可以将 ref 指向任何值。但是,ref 最常见的用法是访问 DOM 元素。例如,如果你想以编程方式聚焦一个输入框,这种用法就会派上用场。当你将 ref 传递给 JSX 中的 `ref` 属性时,比如 `<div ref={myRef}>`,React 会将相应的 DOM 元素放入 `myRef.current` 中。你可以在 [使用 ref 操作 DOM](/learn/manipulating-the-dom-with-refs) 中阅读更多相关信息。
=======
You can point a ref to any value. However, the most common use case for a ref is to access a DOM element. For example, this is handy if you want to focus an input programmatically. When you pass a ref to a `ref` attribute in JSX, like `<div ref={myRef}>`, React will put the corresponding DOM element into `myRef.current`. Once the element is removed from the DOM, React will update `myRef.current` to be `null`. You can read more about this in [Manipulating the DOM with Refs.](/learn/manipulating-the-dom-with-refs)
>>>>>>> 68f417a600c7d7b8c4131e39f8a843a856ae3909
你可以将 ref 指向任何值。但是,ref 最常见的用法是访问 DOM 元素。例如,如果你想以编程方式聚焦一个输入框,这种用法就会派上用场。当你将 ref 传递给 JSX 中的 `ref` 属性时,比如 `<div ref={myRef}>`,React 会将相应的 DOM 元素放入 `myRef.current` 中。当元素从 DOM 中删除时,React 会将 `myRef.current` 更新为 `null`。你可以在 [使用 ref 操作 DOM](/learn/manipulating-the-dom-with-refs) 中阅读更多相关信息。

<Recap>

Expand Down
6 changes: 1 addition & 5 deletions src/content/reference/react/useMemo.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,7 @@ export default function TodoList({ todos, tab, theme }) {

切换选项卡感觉很慢,因为它迫使减速的 `List` 重新渲染。这是预料之中的,因为选项卡 `tab` 已更改,因此你需要在屏幕上展示用户的新选择。

<<<<<<< HEAD
接下来,尝试切换主题。**感谢 `useMemo`[`memo`](/reference/react/memo),尽管被人为减速了,但是它还是很快**!由于作为依赖性传递给 `useMemo``todos``tab` 都没有发生改变,因此 `visibaleItems` 不会发生改变。由于 `visibleItems` 数组从上一次渲染之后就没有发生改变,所以 `List` 会跳过重新渲染。
=======
Next, try toggling the theme. **Thanks to `useMemo` together with [`memo`](/reference/react/memo), it’s fast despite the artificial slowdown!** The `List` skipped re-rendering because the `visibleTodos` array has not changed since the last render. The `visibleTodos` array has not changed because both `todos` and `tab` (which you pass as dependencies to `useMemo`) haven't changed since the last render.
>>>>>>> 68f417a600c7d7b8c4131e39f8a843a856ae3909
接下来,尝试切换主题。**感谢 `useMemo`[`memo`](/reference/react/memo),尽管被人为减速了,但是它还是很快**!由于作为依赖性传递给 `useMemo``todos``tab` 都没有发生改变,因此 `visibaleTodos` 不会发生改变。由于 `visibleTodos` 数组从上一次渲染之后就没有发生改变,所以 `List` 会跳过重新渲染。

<Sandpack>

Expand Down

0 comments on commit 82075f4

Please sign in to comment.