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/learn/manipulating-the-dom-with-refs.md
+10-14Lines changed: 10 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -647,7 +647,7 @@ However, this doesn't mean that you can't do it at all. It requires caution. **Y
647
647
- Refs are a generic concept, but most often you'll use them to hold DOM elements.
648
648
- You instruct React to put a DOM node into `myRef.current` by passing `<div ref={myRef}>`.
649
649
- Usually, you will use refs for non-destructive actions like focusing, scrolling, or measuring DOM elements.
650
-
- A component doesn't expose its DOM nodes by default. You can opt into exposing a DOM node by using `forwardRef` and passing the second `ref`argument down to a specific node.
650
+
- A component doesn't expose its DOM nodes by default. You can opt into exposing a DOM node by using the `ref`prop.
651
651
- Avoid changing DOM nodes managed by React.
652
652
- If you do modify DOM nodes managed by React, modify parts that React has no reason to update.
653
653
@@ -1049,7 +1049,7 @@ Make it so that clicking the "Search" button puts focus into the field. Note tha
1049
1049
1050
1050
<Hint>
1051
1051
1052
-
You'll need `forwardRef` to opt into exposing a DOM node from your own component like `SearchInput`.
1052
+
You'll need to pass `ref` as a prop to opt into exposing a DOM node from your own component like `SearchInput`.
0 commit comments