Skip to content

Commit e308bf2

Browse files
authored
Merge pull request #59175 from nkdengineer/fix/58885
App crashes after viewing card transactions and reporting card fraud
2 parents a5b1c0b + 515276a commit e308bf2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/Modal/BaseModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ function BaseModal(
9797
const safeAreaInsets = useSafeAreaInsets();
9898

9999
const isVisibleRef = useRef(isVisible);
100+
const hideModalCallbackRef = useRef<(callHideCallback: boolean) => void>();
101+
100102
const wasVisible = usePrevious(isVisible);
101103

102104
const uniqueModalId = useMemo(() => modalId ?? ComposerFocusManager.getId(), [modalId]);
@@ -144,13 +146,17 @@ function BaseModal(
144146
};
145147
}, [isVisible, wasVisible, onClose, type]);
146148

149+
useEffect(() => {
150+
hideModalCallbackRef.current = hideModal;
151+
}, [hideModal]);
152+
147153
useEffect(
148154
() => () => {
149155
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
150156
if (!isVisibleRef.current) {
151157
return;
152158
}
153-
hideModal(true);
159+
hideModalCallbackRef.current?.(true);
154160
},
155161
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
156162
[],

0 commit comments

Comments
 (0)