October 2019
Intermediate to advanced
426 pages
11h 49m
English
In order to know whether an element is currently focused, we can use the useFocus Hook as follows:
import React from 'react'import { useFocus } from 'react-hookedup'
export default function UseFocus () { const { focused, bind } = useFocus()
return ( <div> <input {...bind} value={focused ? 'focused' : 'not focused'} /> </div> )}
As we can see, the Focus Hook makes it much easier to handle focus events. There is no need to define our own handler functions anymore.
Read now
Unlock full access