export function useFocus()

in Output/GrokBeta/JS/contextual_experiment/translate_to_react/1731676402/src/utils/focus.ts [4:14]


export function useFocus<T extends HTMLElement>(shouldFocus: boolean) {
    const ref = useRef<T>(null);

    useEffect(() => {
        if (shouldFocus && ref.current) {
            ref.current.focus();
        }
    }, [shouldFocus]);

    return ref;
}