Front End Development Libraries Projects - Build a 25 + 5 Clock

Hey there,

How can I modify my 25 + 5 project so that the countdown reaches 00:00 when switching from the session countdown to the break countdown, rather than after both session and break counts are complete?

Here is my sample code:

 tick() {
    if (this.state.timeTicking) {
      this.setState(prevState => {
        if (prevState.session_length > 0) {
          return { session_length: prevState.session_length - 1 };
        } else if (prevState.break_length > 0) {
          return { break_length: prevState.break_length - 1 };
        } else if (prevState.session_length === 0 && prevState.break_length === 0) {
          // Ensure both session and break lengths are 0 before switching
          return {
            session_length: this.state.initial_session_length,
            break_length: this.state.initial_break_length,
          };
        }
      });
    }
  }

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.