I am trying to keep a global reference on my custom component and use it other places but somehow my hook useHookWithRefValue doesn't return me update ref value, though I have found the workaround with useHookWithRef but I am trying to avoid ref.current every time. What could be reason behind this behaviour?
What is the explanation behind this?
import React from "react";
export const textFieldRef = React.createRef(null);
export function useHookWithRef() {
return textFieldRef; // Works!!
}
export function useHookWithRefValue() {
return textFieldRef.current; // Always returns null
}