mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
420aa4a657
React File Tree GitOrigin-RevId: fb3141ba8cd9ca0d68e87edb74764a360144c8fe
18 lines
374 B
JavaScript
18 lines
374 B
JavaScript
import { createRef, useEffect } from 'react'
|
|
|
|
export function useRefWithAutoFocus() {
|
|
const autoFocusedRef = createRef()
|
|
|
|
useEffect(
|
|
() => {
|
|
if (autoFocusedRef.current) {
|
|
requestAnimationFrame(() => {
|
|
if (autoFocusedRef.current) autoFocusedRef.current.focus()
|
|
})
|
|
}
|
|
},
|
|
[autoFocusedRef]
|
|
)
|
|
|
|
return { autoFocusedRef }
|
|
}
|