As the call for compileProceduresApi is send it takes too much time to fetch. So after getting the response in case of failed response i want to open a modal which is written in “else” block. But the states setModalType and setOpenModal are not getting set. I have tried useEffect, promises, setTimeout but nothing is updating the state.
case "Compile Procedures":
try {
setLoading(true);
const response = await compileProceduresApi({ cabinetName });
if (response.Status === 0) {
toast.success("All Proc`your text`edures Compiled successfully!");
handleClose();
} else {
toast.error(response.Error);
const response1 = await MissedProceduresApi({ cabinetName });
setMissedProcedure(response1);z
setModalType("MissedProcedure");
setOpenModal(true);
}
} catch (error) {
console.error("Error calling Compile Procedures:", error);
} finally {
setLoading(false);
}
break;
I have used useEffect to trigger the state.
Used promises to call the compileProceduresApi…still not working.
SetTimeout for setting the state is not working.
Draav Jain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1