Skip to content

SzymonMatynia/use-outside-click-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React outside click hook

React use outside click hook. It's a simple hook that allows you to detect clicks outside of a component.

Simple example

import {useState} from 'react';
import useOutsideClick from 'use-outside-click-hook';

const ExampleComponent = () => {
  const [show, setIsClicked] = useState(false);

  const ref = useOutsideClick(() => {
    setIsClicked(true);
  });

  return (
    <div ref={ref}>
      {isClicked ? 'Clicked outside' : 'Waiting for click outside'}
    </div>
  );
};

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published