how to update state in javascript in every 5 seconds in functional componenet code example
Example: react function being called every minute
componentDidMount() {
this.interval = setInterval(() => this.setState({ time: Date.now() }), 1000);
}
componentWillUnmount() {
clearInterval(this.interval);
}