Skip to content

Commit 682146c

Browse files
committed
fix(showcase): replace deprecated useModalPortalRoot from modal example with portal
1 parent 30e92c6 commit 682146c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

apps/showcase/app/modal.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { PortalHost, useModalPortalRoot } from '@rn-primitives/portal';
1+
import { PortalHost } from '@rn-primitives/portal';
22
import * as React from 'react';
3-
import { View } from 'react-native';
3+
import { Platform, View } from 'react-native';
44
import { useSafeAreaInsets } from 'react-native-safe-area-context';
5+
import { FullWindowOverlay } from 'react-native-screens';
56
import { Button } from '~/components/ui/button';
67
import { Input } from '~/components/ui/input';
78
import {
@@ -16,18 +17,20 @@ import {
1617
import { Text } from '~/components/ui/text';
1718
import { H1, Muted } from '~/components/ui/typography';
1819

20+
const CUSTOM_PORTAL_HOST_NAME = 'modal-example';
21+
const WindowOverlay = Platform.OS === 'ios' ? FullWindowOverlay : React.Fragment;
22+
1923
export default function ModalScreen() {
2024
const insets = useSafeAreaInsets();
21-
const { sideOffset, ...rootProps } = useModalPortalRoot();
2225
const contentInsets = {
2326
top: insets.top,
24-
bottom: insets.bottom + Math.abs(sideOffset),
27+
bottom: insets.bottom,
2528
left: 16,
2629
right: 16,
2730
};
2831

2932
return (
30-
<View {...rootProps}>
33+
<>
3134
<View className='flex-1 justify-center items-center'>
3235
<View className='p-4 native:pb-24 max-w-md gap-6'>
3336
<View className='gap-1'>
@@ -46,9 +49,8 @@ export default function ModalScreen() {
4649
</SelectTrigger>
4750
<SelectContent
4851
insets={contentInsets}
49-
sideOffset={sideOffset}
5052
className='w-full'
51-
portalHost='modal-example'
53+
portalHost={CUSTOM_PORTAL_HOST_NAME}
5254
>
5355
<SelectGroup>
5456
<SelectLabel>Roles</SelectLabel>
@@ -81,7 +83,9 @@ export default function ModalScreen() {
8183
</View>
8284
</View>
8385
</View>
84-
<PortalHost name='modal-example' />
85-
</View>
86+
<WindowOverlay>
87+
<PortalHost name={CUSTOM_PORTAL_HOST_NAME} />
88+
</WindowOverlay>
89+
</>
8690
);
8791
}

0 commit comments

Comments
 (0)