client/src/components/general/ClickAway.js
/**
 * Hook that alerts clicks outside of the passed ref
 */
Hook that alerts clicks outside of the passed ref
Hook that alerts clicks outside of the passed ref
function useOutsideAlerter(ref, onClickAway) {
  useEffect(() => {
    function handleClickOutside(event) {
      if (ref.current && !ref.current.contains(event.target)) {
        onClickAway()
      }
    }
    document.addEventListener("mousedown", handleClickOutside);
    return () => {
      document.removeEventListener("mousedown", handleClickOutside);
    };
  }, [ref]);
}
function useOutsideAlerter ( ref , onClickAway ) { useEffect ( ( ) => { function handleClickOutside ( event ) { if ( ref . current && ! ref . current . contains ( event . target ) ) { onClickAway ( ) } } document . addEventListener ( "mousedown" , handleClickOutside ) ; return ( ) => { document . removeEventListener ( "mousedown" , handleClickOutside ) ; } ; } , [ ref ] ) ; }
Hook that alerts clicks outside of the passed ref
Hook that alerts clicks outside of the passed ref
/**
     * Alert if clicked on outside of element
     */ // Bind the event listener // Unbind the event listener on clean up