const handlePress=(day)=>{ setData(day); //`day` is set here but not applied immediately setName(`${events[rand]}`) datas.push(data); //data is the previous data, not `day` console.log(datas); }