我正在开发应用程序播放器。参见下图:
进度条必须显示当前时间,但是每打setInterval()
,我的组件都会重新渲染所有内容。这导致我的应用运行缓慢。
这是我的代码:
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.
}