**I'm trying to create an array with 5 values which I could use with nameArray[number]. I think that the declaration of the array is wrong but I don't know how I can fix it. My idea is that: I have 5 buttons, when I click one of this, only one value of the 5 values in the state array change from false to true. **
constructor(props) {
super(props);
this.state = {
activeButtons: [false, false, false, false, false]
};
}
cliccato = (e) => {
e.preventDefault();
const number = parseInt(e.target.id);
this.setState(
{
activeButtons: !this.state.activeButtons[number],
},
() => {
console.log(" "+ this.state.activeButtons[number]);
}
);
}