New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

use-initial-focus

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-initial-focus

React hook for auto focus on an element after rendering

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

use-initial-focus

NPM version NPM yearly download

React hook for auto focus on an element after rendering.
Usually, If we just want to focus on an element when it mounts (initially renders) a simple use of the autoFocus attribute will do.
But in the nested components we are difficult to handle initial focus element, for examples: Modal, Popover

Installation

yarn add use-initial-focus

Usage

Example: https://codesandbox.io/s/use-initial-focus-example-c8eyq

import {useFocus} from 'use-initial-focus';

const MyComponent = () => {
  const initialFocus = useFocus();

  return <button ref={ref}>My Button</button>;
};

License

MIT

Keywords

react hook

FAQs

Package last updated on 04 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts