0
Why "current" in inputRef.current.focus()?
Using useRef I create a reference to an input element named inputRef. To set focus on the element I call: inputRef.current.focus() What does "current" mean and why is it needed? Why not just: inputRef.focus() ?
1 ответ
+ 1
useRef return an object that can hold a mutable value in its .current property.
If you pass a ref object to React with <div ref={myRef} />, React will set its .current property to the corresponding DOM node whenever that node changes.