This approach uses a useCallback and passes the resulting function in place of a ref. It works correctly, but two main questions:
Is "function as ref" a common enough pattern? Are there a lot of risks such as downstream propagation? Or if some other effect may want to have an element's ref?
Are there any performance issues if the callback is not aligned with useEffect or useLayoutEffect timing?
This approach uses a
useCallback
and passes the resulting function in place of aref
. It works correctly, but two main questions:useEffect
oruseLayoutEffect
timing?