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

这里是不是每次onstart都会重置时间,而不是继续上次停止的时间? #1

Open
zhangruidong opened this issue Mar 11, 2019 · 2 comments

Comments

@zhangruidong
Copy link

startTime: new Date(),

@zzm1220
Copy link

zzm1220 commented Mar 29, 2019

我也发现这个问题了,每次停止后在开始都是重新计算

@jydeng
Copy link

jydeng commented Feb 19, 2021

 onStart = () => {
    if (this.state.startTime && this.state.currentTime) {
      this.setState({
        isStarted: true,
      });
    } else {
      this.setState({
        isStarted: true,
        startTime: new Date(),
        currentTime: new Date(),
      });
    }

    this.intervalHandle = setInterval(() => {
      this.setState({ currentTime: new Date() });
    }, 1000 / 60);
  };

onStart 改造一下,可以解决这个问题。

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

3 participants