2.0.0 • Published 5 years ago

use-click-outside v2.0.0

Weekly downloads
3,177
License
MIT
Repository
github
Last release
5 years ago

React hook to execute callback when a click is happened outside of component.

Install

yarn add use-click-outside

Usage

import React, { useRef } from 'react';
import useClickOutside from 'use-click-outside';

const Modal = ({ onClose }) => {
  const ref = useRef();
  useClickOutside(ref, onClose);

  return <dialog ref={ref}>Hello, World!</dialog>;
};

Or if you need a custom event type instead of default 'click', third parameter can be passed:

  useClickOutside(ref, onClose, 'mousedown');

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

2.0.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago