UNPKG

web-api-hooks

Version:

Essential set of React Hooks for convenient Web API consumption.

17 lines (16 loc) 416 B
/** * Tracks focus state of an element. * * @returns Whether the element has focus, and props to be spread over the element under observation. * * @example * function Component() { * const [isFocused, bindFocus] = useFocus(); * // ... * return <ElementToObserve {...bindFocus} />; * } */ export default function useFocus(): [boolean, Readonly<{ onFocus: () => void; onBlur: () => void; }>];