Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pavel-surinin/6fc3c8a2a82469f2bb79dad57bf107d5 to your computer and use it in GitHub Desktop.
Save pavel-surinin/6fc3c8a2a82469f2bb79dad57bf107d5 to your computer and use it in GitHub Desktop.
class Comp extends Component {
constructor(props) {
super(props)
this.state = {
fancy: {
component: <Modal onClose={() => closeModal('fancy')} />,
isActive: false
},
cool: {
component: <Modal onClose={() => closeModal('cool')} />,
isActive: false
}
}
}
closeModal = name => {
this.state.[name].isActive = false
this.setState({...this.state})
}
showModal = (name) => {
this.state.modals[name].isActive = true
this.setState({...state})
}
render() {
{ showModal } = this
return [showModal('fancy'), showModal('cool')]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment