mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:13:46 -05:00
ba4300d9e1
Migrate "Add Files" modal to React GitOrigin-RevId: fc5235108ee65294e3176da9c327791c34aa5b3c
15 lines
357 B
JavaScript
15 lines
357 B
JavaScript
import { createRef, useEffect } from 'react'
|
|
|
|
export function useRefWithAutoFocus() {
|
|
const autoFocusedRef = createRef()
|
|
|
|
useEffect(() => {
|
|
if (autoFocusedRef.current) {
|
|
window.requestAnimationFrame(() => {
|
|
if (autoFocusedRef.current) autoFocusedRef.current.focus()
|
|
})
|
|
}
|
|
}, [autoFocusedRef])
|
|
|
|
return { autoFocusedRef }
|
|
}
|