i have an issue this is issue is function i create to clear and collapse my information doesn't work correctly here need i press two times to work.
const collapseItemList = (item: Speciality) => { const newSpecialty = specialtiesList.map((specialty) => { if (specialty.id === item.id) { return { ...specialty, status: !specialty.status, }; } return specialty; }); setSpecialtiesList(newSpecialty); //this part of code is for clear an array a recive from db const newSpecialtyData = dataSpecialties.filter((specialty) => { if (specialty.specialtyId === Number(item.id)) { return false } return true; }); setDataSpecialtes(newSpecialtyData); };
i need clear this information and collapse my info, image below represent his opened with this info i need close her in only one press