Do not pass ref.current
but ref
itself. If you set a property on an object , any other code may see that property right away as long as it has access to the object.
The object is ref
, in this case.
That way you may access up-to-date DOM element whenever you need it.
That is what useRef is for.