I have a modal in a child component that handles a delete function in the parent component. The child is holding the state of the modal (open or closed) as this seems the most logical place for it.
Parent
removeItem() {
console.log('clicked');
};
...
<DeleteButton deleterecord={()=>this.removeItem(data.row._original._id)}/>
Child
close() {
this.setState({ showModal: false })
};
open() {
this.setState({ showModal: true })
};
render() {
return(
<div>
<Button
bsStyle="primary"
bsSize="small"
onClick={this.open.bind(this)}
>
Delete
</Button>
<Modal
show={this.state.showModal}
onHide={this.close.bind(this)}
bsSize="small"
>
...
How should I close the modal from the parent after the removeItem code has run.