I have a simple section where user can click a button, now I want on click to change (toggle) the color of the text using react hooks here is what I have so far.'
const [textColor, setTextColor] = useState('black');
const handleChnageTextColor = (e) => {
setTextColor('#CCCCCC');
}
return(
<>
<label onClick={handleChnageTextColor} className="switch">
<input type="checkbox" />
<span className="slider round" />
</label>
<small style={{ color:textColor}} className="switch-container_text">advanced view</small>
</>
)
so the initial color is black on click I am changing color to #CCCCCC now when I click again the color is not changing.
What do I need to add to make this toggle between these two colors on click?