1class Child extends React.Component {
2 constructor(){}
3 dismiss() {
4 this.props.unmountMe();
5 }
6 render(){
7 // code
8 }
9}
10
11class Parent ...
12 constructor(){
13 super(props)
14 this.state = {renderChild: true};
15 this.handleChildUnmount = this.handleChildUnmount.bind(this);
16 }
17 handleChildUnmount(){
18 this.setState({renderChild: false});
19 }
20 render(){
21 // code
22 {this.state.renderChild ? <Child unmountMe={this.handleChildUnmount} /> : null}
23 }
24
25}
26