Replies: 1 comment
-
I recommend building a custom navigator instead. The stack navigators are not built to handle different layouts. https://reactnavigation.org/docs/custom-navigators/ If you think your case is a common use case, you can also create a feature request: https://react-navigation.canny.io/feature-requests |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an app that has a two kinds of navigator depending on the device its running on, something like this:
This root navigator is then simply nested under the
NavigationContainer
.The problem is when switching from desktop to mobile navigation, the whole application reloads and we lost track of the navigation. This can for example happen when the user is on desktop and modify its browser window size, the windows could get to the size where its considered too small to render the desktop navigation and start showing the mobile (drawer) navigation instead.
Someone with a similar issue on stackoverflow: Responsive Navigator in React Navigation
At first I though I might just save the navigation state and reload it when a "device change" is detected, but it doesn't work because screens' "keys" do not match (different screen instances are used after a device switch).
I also tried saving the
window.location.pathname
and then navigate to that particularpathname
(usingLinking.openURL
), but it reloads the app and is not the right solution.Is there a way to achieve this?
Additional stuff that might be related
In case it matters, the useDeviceQuery is the following:
Beta Was this translation helpful? Give feedback.
All reactions