Skip to main content
Version: 5.0.3



Outside click(for a ref) event as hook for React.


npm install --save rooks

Importing the hook#

import { useOutsideClick } from 'rooks';


function Demo() {
const pRef = useRef();
function outsidePClick() {
alert('Clicked outside p');
useOutsideClick(pRef, outsidePClick);
return (
<p ref={pRef}>Click outside me</p>
render(<Demo />);

Codesandbox Example#

Basic usage#

Join Bhargav's discord server#

You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.

Last updated on by imbhargav5