@@ -646,21 +646,12 @@ button {
646646
647647<Recap >
648648
649- <<<<<<< HEAD
650649- Refs 是一个通用概念,但大多数情况下你会使用它们来保存 DOM 元素。
651650- 你通过传递 ` <div ref={myRef}> ` 指示 React 将 DOM 节点放入 ` myRef.current ` 。
652651- 通常,你会将 refs 用于非破坏性操作,例如聚焦、滚动或测量 DOM 元素。
653- - 默认情况下,组件不暴露其 DOM 节点。 你可以通过使用 ` forwardRef ` 并将第二个 ` ref ` 参数传递给特定节点来暴露 DOM 节点。
652+ - 默认情况下,组件不暴露其 DOM 节点。 你可以通过使用 ` ref ` 属性来暴露 DOM 节点。
654653- 避免更改由 React 管理的 DOM 节点。
655654- 如果你确实修改了 React 管理的 DOM 节点,请修改 React 没有理由更新的部分。
656- =======
657- - Refs are a generic concept, but most often you'll use them to hold DOM elements.
658- - You instruct React to put a DOM node into ` myRef.current ` by passing ` <div ref={myRef}> ` .
659- - Usually, you will use refs for non-destructive actions like focusing, scrolling, or measuring DOM elements.
660- - A component doesn't expose its DOM nodes by default. You can opt into exposing a DOM node by using the ` ref ` prop.
661- - Avoid changing DOM nodes managed by React.
662- - If you do modify DOM nodes managed by React, modify parts that React has no reason to update.
663- >>>>>>> fc29603434ec04621139738f4740caed89d659a7
664655
665656</Recap >
666657
@@ -1060,11 +1051,7 @@ img {
10601051
10611052<Hint >
10621053
1063- <<<<<<< HEAD
1064- 你需要 ` forwardRef ` 来主动从你自己的组件中暴露一个 DOM 节点,比如 ` SearchInput ` 。
1065- =======
1066- You'll need to pass ` ref ` as a prop to opt into exposing a DOM node from your own component like ` SearchInput ` .
1067- >>>>>>> fc29603434ec04621139738f4740caed89d659a7
1054+ 你需要使用 ` ref ` 属性来主动从你自己的组件中暴露一个 DOM 节点,比如 ` SearchInput ` 。
10681055
10691056</Hint >
10701057
@@ -1149,29 +1136,14 @@ export default function SearchButton({ onClick }) {
11491136```
11501137
11511138``` js src/SearchInput.js
1152- <<<<<< < HEAD
1153- import { forwardRef } from ' react' ;
1154-
1155- export default forwardRef (
1156- function SearchInput (props , ref ) {
1157- return (
1158- < input
1159- ref= {ref}
1160- placeholder= " 找什么呢?"
1161- / >
1162- );
1163- }
1164- );
1165- ====== =
11661139export default function SearchInput ({ ref }) {
11671140 return (
11681141 < input
11691142 ref= {ref}
1170- placeholder= " Looking for something? "
1143+ placeholder= " 找什么呢? "
11711144 / >
11721145 );
11731146}
1174- >>>>>> > fc29603434ec04621139738f4740caed89d659a7
11751147```
11761148
11771149``` css
0 commit comments