In my react app I have an initial state like this:
state= {
graphBackgroundColor: '#fff',
graphLabelColor: '#000',
}
I have a checkbox that calls this function:
toggleCOlor = event => {
console.log('toggling color');
this.setState({
graphBackgroundColor: '#000',
graphLabelColor: '#fff',
renderCalories: event.target.value === 10
});
}
This works functionally, but no matter whether the ckeckbox is checked or not the colors will now stay what they were set to in that function. How can I make this to toggle so that if the checkbox is checked then graphBackgroundColor is #000 and if it's unchecked it's #fff?