-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
State Preservation Issue with Nested Navigators in Voyager #383
Comments
I've encountered this as well, by the way. I have Voyager pretty deeply integrated into my app, so I may just end up having to submit a fix PR myself here sometime soon. |
Have you tried setting |
@shpasha Yeah, that worked for me. But It would be great if there was documentation on why this parameter is for |
@pitampoudel how are you obtaining the parent navigator? I am setting the |
To obtain the parent navigator I am using this => val parentNavigator = LocalNavigator.currentOrThrow.parent and is working for me. |
I am currently working on a project that uses Voyager for navigation. My application has a hierarchical structure of navigators and screens, which is causing an issue with state preservation.
Here’s the structure of my navigators and screens:
A root Navigator is present at the main level.
Inside this root Navigator, there is a HomeScreen.
Within the HomeScreen, I have another TabNavigator which contains three tabs: TabA, TabB, and TabC.
In TabA, I have constructed a TabAScreenModel using the getScreenModel() composable function. This TabAScreenModel is provided by Koin.
The issue arises when I navigate from HomeScreen (which is currently displaying TabA) to another screen (ScreenX) using the parent navigator. ScreenX is not inside the TabNavigator, but is instead a part of the root navigator.
When I navigate back to HomeScreen from ScreenX, the TabAScreenModel associated with TabA is destroyed and re-constructed. This results in the loss of its previous state.
I would like to preserve the existing state of TabAScreenModel when navigating away from HomeScreen and then returning to it. Any guidance or suggestions on how to achieve this would be greatly appreciated.
The text was updated successfully, but these errors were encountered: