-
released this
2023-07-26 09:54:02 +03:00 | 55 commits to main since this releaseNew Features
- Added
useOnClickOutsidehook. 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
useOnClickOutsidehook 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
-
Source code (ZIP)
0 downloads
-
Source code (TAR.GZ)
0 downloads
- Added