Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day1 Record这样写效率是不是会很低啊 #69

Open
connono opened this issue May 31, 2018 · 1 comment
Open

Day1 Record这样写效率是不是会很低啊 #69

connono opened this issue May 31, 2018 · 1 comment

Comments

@connono
Copy link

connono commented May 31, 2018

我按照思路写了一个类似的,放到安卓虚拟机上跑。在计次的时候,就算是4G的内存还是会显得很卡,但是在没有写记录之前,之前的操作都是很流畅的,想知道是什么原因导致的,state的结构与您的基本一致。
计次的时候更新state操作为
let newRecord = Object.assign(this.state);
newRecord.recordTime = (new Date()).getTime();
newRecord.count++;
if (newRecord.count > 8) {
newRecord.record.pop();
}
newRecord.record.unshift({
title: "计次" + newRecord.count,
time: this.state.currentTime
});
this.setState(newRecord);

@MrWait
Copy link

MrWait commented Aug 1, 2018

把计时器的Interval时间改长。
从setState更新数据到界面反馈,需要完成一次DOM更新,速度可想而知。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants