-
-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v4] BottomSheetModal in react navigation modal #832
Comments
Hi Livijn, we had the same bug with "createNativeStackNavigator". Using "createStackNavigator" from "@react-navigation/stack" fixed it for us. Hope that helps! |
I don't want to drop the benefits of using the native stack for this purpose. Thanks though. |
hi @Livijn, did you find a workaround for this one? |
Nope, not yet. Still waiting for @gorhom to reply. |
right, I ended up using hope this helps a bit in the meantime |
If I wrap it like this: What way did you do it? |
it might be either that you didn't add style={[StyleSheet.absoluteFill]} or that I'm not using the modal |
I did add the correct styling. For now, I guess I'll go with the non-native stack navigator. |
Guys, it worked for me |
|
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue was closed because it has been stalled for 5 days with no activity. |
Hello! I figured a workaround which allow the use of any BottomSheetModal inside react-navigation's native modal screen: For it to work, you must place a PortalProvider inside your base BottomSheetModalProvider (the one which is usually located inside you App.tsx file), this will be useful for later. Example:
Then, wrap every one of your BottomSheetModal inside a Portal component. This will force the sheet to render inside the react-navigation's native modal and not higher in the tree. My solution was to use a Context.Provider inside Hope this will help, have a nice day ☀️ |
Adding a I got mine working simply by wrapping my react-navigation modal screen's contents in a function AppStack() {
return (
<NativeStack.Navigator>
{/* ... */}
<NativeStack.Group screenOptions={{ presentation: 'modal' }}>
<NativeStack.Screen
name="MyScreenThatNeedsToBeAbleToOpenABottomSheetModal"
component={MyScreenThatNeedsToBeAbleToOpenABottomSheetModal}
/>
</NativeStack.Group>
</NativeStack.Navigator>
)
}
function MyScreenThatNeedsToBeAbleToOpenABottomSheetModal() {
return (
<BottomSheetModalProvider>
{/* Screen content here, and one of these children can now open a BottomSheetModal */}
</BottomSheetModalProvider>
)
} |
I made a PR #1086 to fix this issue, hope it will be merged soon :) |
Not sure why this works but it does, thank you so much! |
In my case, instead of using a react native navigation modal screen, I instead used a normal screen, but modified the animation to look like that of a modal. I know this might be the case for some of us. In other words, instead of <Stack.Screen
name="ModalScreen"
component={ModalScreen}
options={{presentation: 'fullScreenModal', headerShown: false}}
/> I changed the configuration to this: <Stack.Screen
name={ModalScreen}
component={ModalScreen}
options={{
headerShown: false,
animationTypeForReplace: 'push',
animation: 'slide_from_bottom',
}}
/> Again, this doesn't directly solve the issue, but it is a work around I am very comfortable with, as it doesn't break any existing structure I have in place. |
Using this approach in the context of a |
Ultimately I did something like: import { FullWindowOverlay } from 'react-native-screens'
...
const renderContainerComponent = useCallback(
({ children }) => <FullWindowOverlay>{children}</FullWindowOverlay>,
[],
)
...
<BottomSheetModal containerComponent={renderContainerComponent}>
... |
Adding RPReplay_720.mov |
Fixed by wrapping it in useCallback and only setting it on iOS
|
It works for me |
Because React Navigation's native stack renders modals in a new native view above the existing app, so anything rendered in the original root view will appear behind the modal. Wrapping with a
|
It dose make sense |
Bug
The sheet is placed behind the @react-navigation/native modal.
Environment info
Steps To Reproduce
<BottomSheetModal>
in a screen withpresentation: "modal"
.Describe what you expected to happen:
The sheet is placed behind the modal. I expect the sheet to be in front of the modal that hosts the sheet. I've also tried wrapping the modal-component with the provider, but then I get
'BottomSheetModalInternalContext' cannot be null!
.Reproducible sample code
The snack template throws an error:
Cannot convert undefined or null to object
The text was updated successfully, but these errors were encountered: