I got an array and I neeed to go through, select the same items, push a new array and update a state
const uniqueNumberEvent = 'z3werbfhgdhhsbz';
for (var j = 0; j < this.state.events.length; ++j) {
if (this.state.events[j].unique_number_event == uniqueNumberEvent) {
selectedTickets.push(this.state.events[j].tickets)
}
}
this.setState({
tickets: selectedTickets,
});
console.log(this.state.tickets);
But this code create the new array but don't update the state