@rendr-view/use-outside-alerter
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.3 • Public • Published

@rendr-view/use-outside-alerter

A React hook that can trigger a callback function when the user interacts with any content outside the target element.

Installation

yarn add @rendr-view/use-outside-alerter

Example usage

function Comp() {
  const ref = React.useRef();

  useOutsideAlerter(
    ref,
    () => {
      // the user has clicked outside the modal, you may want to close it
    },
  );

  return <div ref={ref} className="Modal">{...content}</div>
} 

Readme

Keywords

none

Package Sidebar

Install

npm i @rendr-view/use-outside-alerter

Weekly Downloads

2

Version

0.0.1-alpha.3

License

MIT

Unpacked Size

20.1 kB

Total Files

17

Last publish

Collaborators

  • fiveid