Does this cause asynchronity?

I have a react class with two methods. They are both called at the same time with onclick.
One method gets a new quote/author (getQuote) and another changing the screen color (changeColor).

All the test pass (random quote machine).

The changeColor method also includes a transition with a delay and transition period.
I added a setTimeout with the getQuote method to help with this delay, but is that enough ? I hope I don’t need to use promises or such

Also, there’s this method:
does it correctly check to see if the previous index is the same and if it is get another index ? So no two quotes are the same right after each other.

     const tempIndex = Math.floor(Math.random() * times);
      prevState => {
        newIndex: tempIndex;
        prevIndex: prevState.newIndex;
        while(this.state.newIndex ===this.prevIndex){
          tempIndex = Math.floor(Math.random() * times);
        return {
          newIndex: tempIndex,
          prevIndex: prevState.newIndex,

It seems to run correctly, I’m just confused why this.state.prevIndex causes an error, so it’s this.prevIndex instead.

Thanks :slight_smile:

Never mind I solved both questions myself. Had a const where it should have been let etc. This thread can be deleted.