fix(flowsContext.tsx): add a setTimeout to prevent updating state with wrong data

The setTimeout function is added to delay the execution of the addFlowToLocalState function by 200 milliseconds. This is done to prevent updating the state with incorrect data.
This commit is contained in:
anovazzi1 2023-12-11 17:57:49 -03:00
commit 6b2f432327

View file

@ -538,7 +538,11 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
const newFlow = createNewFlow(flowData, flow!);
const { id } = await saveFlowToDatabase(newFlow);
newFlow.id = id;
addFlowToLocalState(newFlow);
//setTimeout to prevent update state with wrong state
setTimeout(() => {
addFlowToLocalState(newFlow);
}, 200);
// addFlowToLocalState(newFlow);
return;
}