Skip to content

Instantly share code, notes, and snippets.

@vldvel
Created June 11, 2020 06:31
Show Gist options
  • Save vldvel/063bc833574757926de15735b4395774 to your computer and use it in GitHub Desktop.
Save vldvel/063bc833574757926de15735b4395774 to your computer and use it in GitHub Desktop.
Setting the interval in the WeatherApp component to constantly pull weather data.
class WeatherApp extends Rect.Component {
updateInterval;
componentDidMount() {
this.updateInterval = setInterval(() => {
this.props.getWeatherData();
}, 1000 * 30); // 30 seconds
}
componentWillUnmount() {
clearInterval(updateInterval);
}
render() {
return (
<div>
{this.props.weatherData}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment