diff --git a/src/content/learn/referencing-values-with-refs.md b/src/content/learn/referencing-values-with-refs.md index a36e1957f4..94a7133191 100644 --- a/src/content/learn/referencing-values-with-refs.md +++ b/src/content/learn/referencing-values-with-refs.md @@ -287,7 +287,11 @@ console.log(ref.current); // 5 ## ref 和 DOM {/*refs-and-the-dom*/} +<<<<<<< HEAD 你可以将 ref 指向任何值。但是,ref 最常见的用法是访问 DOM 元素。例如,如果你想以编程方式聚焦一个输入框,这种用法就会派上用场。当你将 ref 传递给 JSX 中的 `ref` 属性时,比如 `
`,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 `
`, 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 diff --git a/src/content/reference/react/useMemo.md b/src/content/reference/react/useMemo.md index 3085fcc45c..1aeaf5be6f 100644 --- a/src/content/reference/react/useMemo.md +++ b/src/content/reference/react/useMemo.md @@ -647,7 +647,11 @@ 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