I have a modal where the user must fill out some forms and save everything that was filled with the button in the module. When the user saves, I would like the modal function to close. I can do this using open
prop on the component Modal
. But if I do this, the modal does not close when I try to do this through closeIcon.
What can I do to allow the user to close Modal using both methods?
Here is my current modal code:
handleCreateButton (evt) {
evt.preventDefault()
this.setState({showModal: false})
}
renderModalForm () {
const {
something,
showModal
} = this.state
return (
<Modal closeIcon closeOnDimmerClick open={showModal} trigger={<Button onClick={() => this.setState({showModal: true})}><Icon className='plus'/>New Challenge</Button>}>
<Modal.Header>My Modal</Modal.Header>
<Modal.Content>
<Form>
<Form.Input
label='Something'
value={something}
onChange={(evt) => this.handleChangeForms('something', evt.target.value)}
/>
<Button onClick={(evt) => this.handleCreateButton(evt)}>Save</Button>
</Form>
</Modal.Content>
</Modal>
)
}
source
share