I have an array tranches: [{ start: moment().format("HH:mm"), end: moment().format("HH:mm") }]
and when I set the value of the tranches[0].start
without setState
I get :
Do not mutate state directly. Use setState()
My code is :
handleAjouter = (start, end, date) => {
this.state.tranches[0].start = start;
this.state.tranches[0].end = end;
this.setState({
tranches: this.state.tranches
});
}
How can I fix it ?