React state changing issue

HI, I’m attempting to change the color of my h1 element using the onclickevent, but the previous color remains

Hi @ayanda :wave:

I’m not a React developer. So maybe I’m completely wrong :grimacing:
The setStyle variable in your code is just a “normal” variable. Shouldn’t it be a state variable like state.text? Maybe the return part can only react to variable changes if they are state variables.
If this is true, you’re clicked() function should use setState() to change a state.setStyle variable.

Have a nice day!
Michael

You need to learn about react state specifically useState hook.