Created
February 28, 2019 18:57
-
-
Save Ranguro/cee05712793775eaf10ff00196ac56cd to your computer and use it in GitHub Desktop.
click handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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