Am trying to revert the color and icon of a button when clicked, but I can’t seem to come up with a good approach to deal with the state
The the color and icon only change one time but can’t seem to revert back to the original once clicked again
I just want to be able to switch the color and icon back and forth on every click
Here’s what I’ve tried so far…
2
Answers
The issue is that your function is setting the icon to a tick and the color to green. Every time you click it it will set it to the same value. I would remove both of this states and put only one – boolean value that checks the state of the button. If it is true, the icon should be a tick and color should be green. If it is false – cross and red.