Eidan
1
Hello there 
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:
nibble
2
Start by changing this event handler
onClick={() => {
this.getRandomIndex;
this.changeColor;
}
}
to
onClick={() => {
this.getRandomIndex();
this.changeColor();
}
}
I have noticed you are setting state in changeColor
event.
setState({
color: Math.floor(Math.random() * this.state.colors.length)
});
but i don’t see color
property when you are initialising state in constructor
Eidan
3
Thank you very much!
I found two mistakes:
- I wrote
color
instead of currentColor
in the function.
- as you mentioned I wrote
color
instead of currentColor
in the constructor.
I just finished my first project! 
1 Like
nibble
4
I am glad it was helpful.
1 Like