Skip to content

Instantly share code, notes, and snippets.

@himanoa
Last active April 24, 2018 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himanoa/078e5304052a0ec51a5c468a37b0e11d to your computer and use it in GitHub Desktop.
Save himanoa/078e5304052a0ec51a5c468a37b0e11d to your computer and use it in GitHub Desktop.
import { Component } from "React";
export const withModal = (InnerComponent) => class extends Component {
constructor() {
this.state = { visible: false };
}
render() {
<div>
<InnerComponent visibleModal={() => this.setState({ visible: true })}/>
<Modal close={() => this.setState({ visible: false })} isVisible={this.state.visible} />
</div>
}
};
// Modalは中でisVisibleを見て
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment