• v1.3.1 f6a33a827d

    CosmicCoder-sudo released this 2023-07-26 09:54:02 +03:00 | 55 commits to main since this release

    New Features

    • Added useOnClickOutside hook. This new hook allows you to easily detect clicks that occur outside of a specified element. This can be useful for things like closing dropdowns, modals, or popups when a user clicks anywhere else on the page.

    How to use

    • The useOnClickOutside hook takes two parameters: an array of refs and a callback function. The hook will call the callback function whenever a click occurs outside of the elements referred to by the refs.
    • Here is a simple usage example:
      const TestComponent = ({ callback }: { callback: () => void }) => {
        const ref = React.useRef<HTMLElement | null>(null);
      
        useOnClickOutside([ref], callback);
      
        return <div ref={ref}>Test Element</div>;
      };
      
    Downloads