Skip to content
This repository has been archived by the owner on Dec 15, 2019. It is now read-only.
/ element-focus Public archive

React hook for check focus state of elements

License

Notifications You must be signed in to change notification settings

sulfureux/element-focus

Repository files navigation

@rehooks/element-focus

React hook for check focus state of elements

Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.

You'll need to install react, react-dom, etc at ^16.7.0-alpha.0

Install

yarn add @rehooks/element-focus

Usage

import useInputValue from '@rehooks/input-value';
import useElementFocus from '@rehooks/element-focus';

function MyComponent() {
  const { isFocused, bind } = useElementFocus();
  // bind = { onFocus: [function], onBlur: [function] }
  return (
    <div>
      <input {...bind} />
      <div>This input is {isFocused ? "focused" : "not focused"}</div>
    </div>
  );
}

About

React hook for check focus state of elements

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published