Skip to content

Commit b40ec93

Browse files
committed
fix: make sure closing view knows how to unregister itself on unmount
1 parent 6bccb69 commit b40ec93

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

package/src/components/UIComponents/PortalWhileClosingView.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
55
import { Portal } from 'react-native-teleport';
66

77
import { useStableCallback } from '../../hooks';
8-
import { setClosingPortalLayout, useOverlayController } from '../../state-store';
8+
import {
9+
clearClosingPortalLayout,
10+
setClosingPortalLayout,
11+
useOverlayController,
12+
} from '../../state-store';
913

1014
type PortalWhileClosingViewProps = {
1115
children: ReactNode;
@@ -58,6 +62,14 @@ export const PortalWhileClosingView = ({
5862
};
5963
}, [insets.top, portalHostName]);
6064

65+
const unregisterPortalHost = useStableCallback(() => clearClosingPortalLayout(portalHostName));
66+
67+
useEffect(() => {
68+
return () => {
69+
unregisterPortalHost();
70+
};
71+
}, [unregisterPortalHost]);
72+
6173
const onWrapperViewLayout = useStableCallback((event: LayoutChangeEvent) => {
6274
const { height, width } = event.nativeEvent.layout;
6375
layoutRef.current = { h: height, w: width };

0 commit comments

Comments
 (0)