Skip to content

Commit 50b2e22

Browse files
authored
Merge pull request Expensify#64865 from bernhardoj/fix/64556-double-modal-hide
Fix double modal hide callbacks when unmounted
2 parents 16ad05d + be86e87 commit 50b2e22

1 file changed

Lines changed: 0 additions & 18 deletions

File tree

src/components/Modal/BaseModal.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ function BaseModal(
109109
const insets = useSafeAreaInsets();
110110

111111
const isVisibleRef = useRef(isVisible);
112-
const hideModalCallbackRef = useRef<(callHideCallback: boolean) => void>(undefined);
113-
114112
const wasVisible = usePrevious(isVisible);
115113

116114
const uniqueModalId = useMemo(() => modalId ?? ComposerFocusManager.getId(), [modalId]);
@@ -160,22 +158,6 @@ function BaseModal(
160158
};
161159
}, [isVisible, wasVisible, onClose, type]);
162160

163-
useEffect(() => {
164-
hideModalCallbackRef.current = hideModal;
165-
}, [hideModal]);
166-
167-
useEffect(
168-
() => () => {
169-
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
170-
if (!isVisibleRef.current) {
171-
return;
172-
}
173-
hideModalCallbackRef.current?.(true);
174-
},
175-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
176-
[],
177-
);
178-
179161
const handleShowModal = useCallback(() => {
180162
if (shouldSetModalVisibility) {
181163
setModalVisibility(true, type);

0 commit comments

Comments
 (0)