useRef() in react
/*
A common use case is to access a child imperatively:
*/
function TextInputWithFocusButton() {
const inputEl = useRef(null);
const onButtonClick = () => {
// `current` points to the mounted text input element
inputEl.current.focus();
};
return (
<>
<input ref={inputEl} type="text" />
<button onClick={onButtonClick}>Focus the input</button>
</>
);
}function TextInputWithFocusButton() {
const inputEl = useRef(null);
const onButtonClick = () => {
// `current` points to the mounted text input element
inputEl.current.focus();
};
return (
<>
<input ref={inputEl} type="text" />
<button onClick={onButtonClick}>Focus the input</button>
</>
);
}
Also in JavaScript:
- fsharp newtonsoft json deserialize
- number pattern js
- how play audio js
- angular elementref
- Did you mean to use React.forwardRef()?
- use property in angular 8
- monk remove
- disable text selection in js
- HIDE BROKEN IMAGES
- return last two values of array in javascript
- jquery bind function to multiple events
- how to add alternate image in img tag in react
- autocomplete react vscode
- javascript email link
- objects are not valid as a react child
- can the name of function be the same with name of variable js
- slice()
- Bidirectionnal model binding
- minimum number of swaps to sort an array javascript
- reactjs web3 components
- scrollbar position
- computed property name javascript
- read file javascript
- regex validate email