Last active
October 10, 2020 16:54
-
-
Save vldvel/d37796e99a7f300dfe22b0f94370e533 to your computer and use it in GitHub Desktop.
setInterval in componentdidMount
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 NewMessages extends Rect.Component { | |
updateInterval; | |
componentDidMount() { | |
this.updateInterval = setInterval(() => { | |
this.props.getNewMessages(); | |
}, 500); | |
} | |
componentWillUnmount() { | |
clearInterval(updateInterval); | |
} | |
render() { | |
return ( | |
<div> | |
{this.props.newMessages} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment