Socialify

Folder ..

Viewing use-autofocus.ts
13 lines (10 loc) • 233.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import { useCallback } from 'react'

const useAutoFocus = () => {
  const inputRef = useCallback((inputElement) => {
    if (inputElement) {
      inputElement.focus()
    }
  }, [])

  return inputRef
}

export default useAutoFocus