Skip to content

Instantly share code, notes, and snippets.

@Ranguro
Created February 28, 2019 18:57
Show Gist options
  • Save Ranguro/cee05712793775eaf10ff00196ac56cd to your computer and use it in GitHub Desktop.
Save Ranguro/cee05712793775eaf10ff00196ac56cd to your computer and use it in GitHub Desktop.
click handler
import React, { Component } from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
const withOutsideClickHandler = (WrappedComponent) => class extends Component {
constructor(props) {
super(props);
this.ref = React.createRef();
this.state = {
open: false,
disabled: true
};
}
render() {
return (
<OutsideClickHandler onOutsideClick={this.onOutsideClick} disabled={this.state.disabled}>
<WrappedComponent {...this.props} ref={this.ref} open={this.state.open} toggleOpen={this.toggleOpen}/>
</OutsideClickHandler>
);
}
};
export default withOutsideClickHandler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment