React calculator - async state?

I’m working on the front end calculator challenge using react. Things were going swimmingly until I wanted to clear the display if the user enters a number after hitting equals. The logic seems sound, but the display doesn’t clear and the new number is added to the operand:

I think the problem is on lines 133-137. As far as I can tell React doesn’t update state fast enough to use in this calculation. Is that the correct interpretation?

  • Should I use another method to store the key variables, and maybe just update display with state?
  • Is there a way to make React update state faster?

Keen to understand rather than just botch my way through.

Thanks in advance!

I assume you mean if the display shows 0 and then the user clicks 0 and then tries to click 4? If that is not what you mean, please walk us through an actual step by step of what you want to happen as things are clicked.

Oops! Sorry, let me edit the post above so this makes sense…

The issue is if the user hits another number after hitting equals.

In other words, if we’ve hit equals and a result is showing, when you hit a new number it should clear the screen and start from that number.