Skip to content

Instantly share code, notes, and snippets.

@BTMPL
Created Dec 22, 2016
Embed
What would you like to do?
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