Comment

Comment by kitsunechaos

I kept writing the same useEffect boilerplate every time I needed to close a dropdown or modal on outside click. So I packaged it.

npm install @kitsunechaos/use-outside-click

Usage:

  useOutsideClick(ref, () => setOpen(false))
- Zero dependencies - TypeScript native - SSR safe (Next.js compatible) - Touch + mouse support - ~400 bytes gzipped

GitHub: github.com/kitsunechaos-labs/use-outside-click npm: npmjs.com/package/@kitsunechaos/use-outside-click

parent kitsunechaos 7 months ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton