Skip to content

Latest commit

 

History

History

2-click-outisde

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

useClickOutside easy #react #event listeners #hooks

by Pawan Kumar @jsartisan

Take the Challenge

Implement a custom hook useClickOutside to handle the click outside of the passed ref element. The hook takes a callback function which will be invoked when the user clicks outside of the passed ref element.

const ref = useRef(null);

useClickOutside(ref, () => {
  console.log("clicked outside");
});

Back Share your Solutions Check out Solutions