use-set-focus
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

use-set-focus

React hook to immediately place the browser's focus to your chosen element on demand.

Installation

npm i use-set-focus

Usage

import useSetFocus from 'use-set-focus';
 
const [inputRef, setInputFocus] = useSetFocus<HTMLInputElement>();
 
const focusOnInputNow = () => {
    setInputFocus();
}
 
return <input ref={inputRef}>;

Dependencies (0)

    Dev Dependencies (23)

    Package Sidebar

    Install

    npm i use-set-focus

    Weekly Downloads

    8

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    9.47 kB

    Total Files

    13

    Last publish

    Collaborators

    • dkershner6