RE

React Onclickoutside

react-onclickoutside

An onClickOutside wrapper for React components

Utilities
react
onclick
outside
onclickoutside
react-onclickoutside
Utilities
javascript
npm
frontend
open source
Stars
1.8k
Weekly
1.9M
Open issues
6
Bundle
~25 kB

Installation

npm install react-onclickoutside

Code example

import { useOnclickoutside } from "react-onclickoutside";

export function Example() {
  const value = useOnclickoutside();
  return <p>{String(value)}</p>;
}

Pros & cons

Pros

  • Actively maintained by pomax
  • 1.9M weekly downloads. Battle tested
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 6 open issues on GitHub

FAQs

Alternatives & similar libraries