React Component for handling some specific component outside click
Table of contents
- Installation
- API
<OutsideClickHandler onOutsideClick useCapture />
- Example
- Development
- Credits
yarn add react-outside-click-handler
<OutsideClickHandler onOutsideClick useCapture />
onOutsideClick
(Function): outside click handleruseCapture
(Boolean): See link's useCapture section (Default:true
)
class Example extends React.Component {
constructor(props) {
super(props);
this.handleOutsideClick = this.handleOutsideClick.bind(this);
}
handleOutsideClick() {
// ...
}
render() {
return (
<div>
<TodoList>
<Todo />
...
</TodoList>
<OutsideClickHandler onOutsideClick={this.handleOutsideClick}>
<InsideComponent />
</OutsideClickHandler>
</div>
);
}
}
yarn start
Then, Go to http://localhost:3000
This component is inspired by airbnb/react-dates's OutsideClickHandler
MIT @ Taehwan, No (taehwanno)