I'm developing an app player. see the picture below:
The progress bar must show the current time, but with every tick of setInterval()
, my component re-renders everything. That's causing my app to be slow.
This is my code:
this.state = {
currentTime: 0,
}
/// ....
const tick = 100;
setInterval(() => {
this.setState({currentTime += tick});
}, tick);
render() {
// This will call every tick (100ms). That's what I don't want, but if I skip it, the progress will not show the current time.
}