I have an object which I have created in state and it is my model for the booking. My addPassenger function should when click create an empty object into array with properties. When I console.log the new array it returns me the array properly but when I execute function nothing happens, no error. Just blank console.
My whole component https://pastebin.com/RLprKJrr
booking: {
id: "",
number: "",
date: "",
bookingStatus: "OPCIJA",
paymentMethod: "MODELA1",
tripID: 1,
passengers: [
{
id: "",
holder: {
email: "",
address: "",
mobile: ""
},
name: "",
surname: "",
passport: "",
idCard: ""
}
]
}
addPassenger = e => {
e.preventDefault();
let passengersArray = [...this.state.booking.passengers];
console.log(passengersArray);
this.setState({
passengers: [...passengersArray, {
id: "",
name: "",
surname: "",
passport: "",
idCard: ""
}]
})
this.checkArrayLength();
}