Created
December 22, 2016 14:46
-
-
Save BTMPL/580eec7ef7e1f01af8304275273010da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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