Skip to content

Commit be86e87

Browse files
committed
fix double modal hide callbacks when unmounted
1 parent 67dc880 commit be86e87

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
@@ -102,8 +102,6 @@ function BaseModal(
102102
const insets = useSafeAreaInsets();
103103

104104
const isVisibleRef = useRef(isVisible);
105-
const hideModalCallbackRef = useRef<(callHideCallback: boolean) => void>(undefined);
106-
107105
const wasVisible = usePrevious(isVisible);
108106

109107
const uniqueModalId = useMemo(() => modalId ?? ComposerFocusManager.getId(), [modalId]);
@@ -153,22 +151,6 @@ function BaseModal(
153151
};
154152
}, [isVisible, wasVisible, onClose, type]);
155153

156-
useEffect(() => {
157-
hideModalCallbackRef.current = hideModal;
158-
}, [hideModal]);
159-
160-
useEffect(
161-
() => () => {
162-
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
163-
if (!isVisibleRef.current) {
164-
return;
165-
}
166-
hideModalCallbackRef.current?.(true);
167-
},
168-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
169-
[],
170-
);
171-
172154
const handleShowModal = useCallback(() => {
173155
if (shouldSetModalVisibility) {
174156
setModalVisibility(true, type);

0 commit comments

Comments
 (0)