Created
June 11, 2020 06:31
-
-
Save vldvel/063bc833574757926de15735b4395774 to your computer and use it in GitHub Desktop.
Setting the interval in the WeatherApp component to constantly pull weather data.
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 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