Supported cryptocurrencies:
BTC BTC
BCH Bitcoin Cash
NANO NANO
0.00015 BCH
EnglishWhere is the error on this React code. [image]

When I am clicking to change the background color I am getting a ReferenceError: Cannot access 'background' before initialization when clicking on the Button {toggleButton} Any idea? Thanks

godzilla34 1 month ago
    Tags:
  • Code
  • Coding
  • React
question_image


kimo2 1 month ago Correct
const newbackground = background !== 'orange' ? 'orange' : 'blue'
setbackground(newbackground)
godzilla34 1 month ago
Yep, this was it. Thanks
Miss Mike 1 month ago
You are confusing the functions. 1. User or use. 2. Separate 'set' and 'background'. 3. Separate 'background' from 'color'.4. You are confusing the functions.