mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 06:01:54 +00: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 }
|
|
}
|