Skip to content

Commit

Permalink
fix(react-refs): ref as a prop starting in React 19
Browse files Browse the repository at this point in the history
  • Loading branch information
sabertazimi committed Dec 15, 2024
1 parent 65b69a0 commit 8a43fbc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions notes/Web/React/ReactBasicNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,18 @@ const FancyButton = React.forwardRef<Ref, Props>(Button)
export default FancyButton
```

#### Prop Refs

Starting in React 19, you can now access ref as a prop for function components:

```tsx
function MyInput({ placeholder, ref }) {
return <input placeholder={placeholder} ref={ref} />
}

<MyInput ref={ref} />
```

#### Callback Refs

```tsx
Expand Down

0 comments on commit 8a43fbc

Please sign in to comment.