Module

useClickOutside

The hooks closes the opened DOM ref when user clicks outside.

View Source client/src/hooks/useClickOutside.tsx, line 3

Example

import { useRef, useState } from "react";

const Header = () => {
const [isOpen, setOpen] = useState(false);
useClickOutside(ref, () => setOpenLanguage(false));
return(
<button ref={ref} onClick={logout}> Log Out </button>
)}