The onclick event on the button does not work for the first click, and it works well from the second. Why is this?

   let button=document.getElementById('button');'lightcoral'?'lightgreen':'lightcoral'; this.setState({bank:bankTwo}):

Is this a javascript challenge?

yes. It is. It’s a react question.

You should not be updating things based on current state outside of this.setState. You need to use the functional version of it.

1 Like

The style does not change for the first click as well. Everything works fines from the second, both the state and the style.

Can you post a link to your project code?