useState in React - creating state to track the click of a button?
https://codesandbox.io/p/sandbox/musing-bash-5hdgh5?embed=1&file=%2Fsrc%2FApp.jsx%3A11%2C31
"Add a new state variable to keep track of the number of times the background color has been changed. Display the number of times the background color has been changed on the page."
So far I have gotten as far as
Now I think I have to put use setTimesClicked in an onClick perhaps, like setBackgroundColor
but state is still baffling me, so I'm not sure.
0 Replies