mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
8c3578e74b
Rename hooks files and move to shared folder GitOrigin-RevId: 9659247b5e767197c3e11acc9a3922ecaab49162
17 lines
373 B
JavaScript
17 lines
373 B
JavaScript
import { useRef, useEffect } from 'react'
|
|
|
|
export function useRefWithAutoFocus() {
|
|
const autoFocusedRef = useRef()
|
|
|
|
useEffect(() => {
|
|
if (autoFocusedRef.current) {
|
|
window.requestAnimationFrame(() => {
|
|
if (autoFocusedRef.current) {
|
|
autoFocusedRef.current.focus()
|
|
}
|
|
})
|
|
}
|
|
}, [autoFocusedRef])
|
|
|
|
return { autoFocusedRef }
|
|
}
|