Supported cryptocurrencies:
BTC BTC
BCH Bitcoin Cash
NANO NANO
XTZ Tezos
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 3 years ago
    Tags:
  • Code
  • Coding
  • React
question_image


kimo2 3 years ago Correct
const newbackground = background !== 'orange' ? 'orange' : 'blue'
setbackground(newbackground)
godzilla34 3 years ago
Yep, this was it. Thanks
Miss Mike 3 years 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.