Skip to content

Instantly share code, notes, and snippets.

@BTMPL
Created December 22, 2016 14:46
Show Gist options
  • Save BTMPL/580eec7ef7e1f01af8304275273010da to your computer and use it in GitHub Desktop.
Save BTMPL/580eec7ef7e1f01af8304275273010da to your computer and use it in GitHub Desktop.
class Parent extends React.Component {
constructor(...args) {
super(args);
this.state = {
renderChild: true
}
this.interval = null;
}
componentDidMount() {
this.interval = setTimeout(() => this.setState({renderChild: false}), 5000);
}
componentWillUnmount() {
clearInterval(this.interval);
}
render() {
return (
<div>
{ this.state.renderChild ? '<Child />' : null }
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment