React HOC OutsideClick
npm install react-hoc-outside-click


1. Import clickOutside component
2. Wrap your main component with function the clickOutside
3. Provide an onClickOutside callback.
``js
import React from 'react';
/ Any component, which will be set onClickOutside /
import Modal from 'modal/Modal';
import clickOutside from 'react-hoc-outside-click';
class AnyComponent extends Component {
state = {
isOpened: false
}
handleClickOutside() {
this.setState({ isOpened: false });
},
render() {
const wrapClickDiv = clickOutside(Modal);
return (
Any content
)
},
});
export default AnyComponent;
``
| Name | Description | Required |
| ------------- |-------------| --- |
| onClickOutside | function that is called when a click happened outside of the component | yes |
MIT