I want to changed boolean state based on the value is passed
class Home extends Component {
constructor(props) {
super(props);
this.state = {
formElement: {
home: true,
booth: false,
summary: false
},
};
}
buttonClickHandler(event, nextView) { //nextView == summary
// nextView == summary then summary would be true and booth would be flase and home would flase too
}
}
Here based on nextView all state value should be reserved.
Thanks in advance..!!
considering you are receiving nextView as home/booth/summary and based on this you want to set corresponding key i.e. formElement[nextView] = true and for other keys i.e. formElement[!nextView] = false.
You can try following:
By the way I feel you might use simpler state variable, if possible. like
then
It is just a thought for https://en.wikipedia.org/wiki/KISS_principle.