react ref focus() code example
Example 1: react focus
const FocusDemo = () => {
const [inputRef, setInputFocus] = useFocus()
return (
<>
>
)
}
const useFocus = () => {
const htmlElRef = useRef(null)
const setFocus = () => {htmlElRef.current && htmlElRef.current.focus()}
return [ htmlElRef, setFocus ]
}
Example 2: cre&atRefs react js
const node = this.myRef.current;