Random quote machine in REACT can't change color

Hello there :slight_smile:

I’m building my Random Quote Machine in React and I have a problem:

I can’t get the color change when I click the random icon.
My code so far.

any ideas?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36.

Challenge: Build a random quote machine

Link to the challenge:

Start by changing this event handler

 onClick={() => {


 onClick={() => {

I have noticed you are setting state in changeColor event.

      color: Math.floor(Math.random() * this.state.colors.length)

but i don’t see color property when you are initialising state in constructor

Thank you very much!

I found two mistakes:

  1. I wrote color instead of currentColor in the function.
  2. as you mentioned I wrote color instead of currentColor in the constructor.

I just finished my first project! :partying_face:

1 Like

I am glad it was helpful.

1 Like