useCallback Might Be What You Meant By useRef & useEffect

Sometimes we respond to React element mounts. The first instinct is to useRef & useEffect. But It’s wrong. What you really need is often useCallback.

setRef returned from useCallback
react-hooks warns about using useRef with useEffect
A sandbox where useRef as deps of useEffect fails to trigger it on time

useCallback

A sandbox where useCallback is used as a ref and detects renders on time

useState

useStateRef

useRefWithCallback