I have a ticket child class that sets the total amount after no of tickets has been been changed the problem i am facing here is setNumber doesn’t seem to work unless setTotal is commented out, i don’t understand this and could use some help regarding this issue
const Booking = () => {
let [total, setTotal] = useState(0)
const Ticket = ({ ticket, index }: any) => {
let [number, setNumber] = useState(0);
const handleChange = (e: any) => {
const order = {
eventid: eventid,
amt: ticket.price * e.target.value,
type: ticket.type,
tickets: e.target.value,
email: userdata!.email,
ticketid: ticket.ticketid,
}
orders[index] = order
//setNumber doesn't seem to work unless setTotal is commented out
setNumber(Number(e.target.value))
console.log(number)
let sum = orders.reduce((accumulator: number, object: any) => {
return accumulator + object.amt;
}, 0)
setTotal(sum)
}
I’ve tried changing adding the setTotal function as a parameter to the child component but it doesn’t seem to work

