React Pomodoro Tests Failing

This is a rough draft of my pomodoro clock.
I can’t seem to get the tests to pass(freezes at test 11) despite the clock working as expected.
I’ve rewritten it from scratch and made several modifications but the tests either proceed and fail at #26 or just gets stuck at #11.
Is there something I’m missing?
I’m almost tempted to fork freecodecamp’s pomodoro on codepen and style it to my liking but I feel like that would be cheating.
Any help or suggestions at all would be appreciated so that I can stop pulling my hair. Thanks in advance.
Here it is: Very Frustrating Pomodoro Clock.

One thing you’re missing is that setState() is asynchronous. You can see it, for example, when you change Break/Session Length - you need to click twice for change to display.

If you use something like this:

let minutes = this.state.minutes // let's say it's 5
this.setState({ minutes: minutes + 1 }); // set this.state.minutes to 6
this.setState({ hours: this.state.minutes }); // set this.state.hours to ???

what do you expect this.state.hours to be?

If you say 6, go read this: https://reactjs.org/docs/react-component.html#setstate

1 Like