diff --git a/src/lib/ModalProvider.tsx b/src/lib/ModalProvider.tsx index 7f71d3e..44a9b03 100644 --- a/src/lib/ModalProvider.tsx +++ b/src/lib/ModalProvider.tsx @@ -93,11 +93,11 @@ const ModalProvider = ({ children, stack }: Props) => { const listener: ModalStateListener = (modalState, error) => { if (modalState) { - setContextValue({ - ...contextValue, + setContextValue(prev => ({ + ...prev, currentModal: modalState.currentModal, stack: modalState.stack, - }) + })) } else console.warn('Modalfy', error) } diff --git a/src/lib/ModalState.ts b/src/lib/ModalState.ts index b55c0a8..74942aa 100644 --- a/src/lib/ModalState.ts +++ b/src/lib/ModalState.ts @@ -363,7 +363,8 @@ export const modalfy = < * @see https://colorfy-software.gitbook.io/react-native-modalfy/api/types/modalprop#closeallmodals */ closeAllModals: (callback?: () => void) => { - ModalState.queueClosingAction({ action: 'closeAllModals', callback }) + ModalState.closeAllModals() + callback?.() }, /** * This function closes the currently displayed modal by default.