Browse Source

Fix ref creation in CustomTextInput component (#2072)

Change React.createRef() to useRef(null)
main
Myron Yeung 5 years ago
committed by GitHub
parent
commit
ba0818beab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      content/docs/refs-and-the-dom.md

2
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} ```javascript{2,3,6,13}
function CustomTextInput(props) { function CustomTextInput(props) {
// textInput must be declared here so the ref can refer to it // textInput must be declared here so the ref can refer to it
let textInput = React.createRef(); let textInput = useRef(null);
function handleClick() { function handleClick() {
textInput.current.focus(); textInput.current.focus();

Loading…
Cancel
Save