Solution to the problem discussed with Dan Abramov here.
implementation:
export default function useQueueFocus(): (elementRef: React.MutableRefObject<HTMLElement | null>) => void {
const isUnmountedRef = useRef(false)
const forceUpdate = useForceUpdate()
const ref = useRef<MutableRefObject<HTMLElement | null> | undefined>(undefined)