Skip to content

Commit 383b389

Browse files
authored
Remove forwardRefs from recap and challenges (#7475)
1 parent c03f029 commit 383b389

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/content/learn/manipulating-the-dom-with-refs.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ However, this doesn't mean that you can't do it at all. It requires caution. **Y
647647
- Refs are a generic concept, but most often you'll use them to hold DOM elements.
648648
- You instruct React to put a DOM node into `myRef.current` by passing `<div ref={myRef}>`.
649649
- 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.
651651
- Avoid changing DOM nodes managed by React.
652652
- If you do modify DOM nodes managed by React, modify parts that React has no reason to update.
653653

@@ -1049,7 +1049,7 @@ Make it so that clicking the "Search" button puts focus into the field. Note tha
10491049

10501050
<Hint>
10511051

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`.
10531053

10541054
</Hint>
10551055

@@ -1134,18 +1134,14 @@ export default function SearchButton({ onClick }) {
11341134
```
11351135

11361136
```js src/SearchInput.js
1137-
import { forwardRef } from 'react';
1138-
1139-
export default forwardRef(
1140-
function SearchInput(props, ref) {
1141-
return (
1142-
<input
1143-
ref={ref}
1144-
placeholder="Looking for something?"
1145-
/>
1146-
);
1147-
}
1148-
);
1137+
export default function SearchInput({ ref }) {
1138+
return (
1139+
<input
1140+
ref={ref}
1141+
placeholder="Looking for something?"
1142+
/>
1143+
);
1144+
}
11491145
```
11501146

11511147
```css

0 commit comments

Comments
 (0)