Browse Source
Fix ref creation in CustomTextInput component (#2072)
Change React.createRef() to useRef(null)
main
Myron Yeung
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
1 additions and
1 deletions
-
content/docs/refs-and-the-dom.md
|
|
@ -168,7 +168,7 @@ You can, however, **use the `ref` attribute inside a function component** as lon |
|
|
|
```javascript{2,3,6,13} |
|
|
|
function CustomTextInput(props) { |
|
|
|
// textInput must be declared here so the ref can refer to it |
|
|
|
let textInput = React.createRef(); |
|
|
|
let textInput = useRef(null); |
|
|
|
|
|
|
|
function handleClick() { |
|
|
|
textInput.current.focus(); |
|
|
|