Skip to content

Can't keep a screen mounted #808

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

Open
florian-milky opened this issue Jun 11, 2020 · 7 comments
Open

Can't keep a screen mounted #808

florian-milky opened this issue Jun 11, 2020 · 7 comments

Comments

@florian-milky
Copy link

Current Behavior

From the docs:

navigation.navigate({ name: SCREEN, key: SCREEN_KEY_A });
navigation.navigate({ name: SCREEN, key: SCREEN_KEY_B });
navigation.navigate({ name: SCREEN, key: SCREEN_KEY_C });
navigation.navigate({ name: SCREEN, key: SCREEN_KEY_D });

then

navigation.navigate({ key: SCREEN_KEY_A }); // will go to screen A FROM screen D

It will unmount B, C and D. (btw I think this should be highlighted more in the docs)
What if I want to keep let's say D mounted? And when I navigate to D again, I want to reuse the same instance.

My use case is a webview that I want to keep mounted in the background.
I found an old question in stackoverflow, never answered https://stackoverflow.com/questions/41818857/keep-react-native-webview-mounted

Expected Behavior

  • I want to have the option to keep a screen mounted and reuse the same instance when I navigate back to it.
@Rangoons
Copy link

Rangoons commented Jun 11, 2020

I've noticed this today too. I believe it was a change that was introduced recently. I would love to know a fix for it.

For reference, in a Stack, the first route/screen is a Tab nav that contains different feeds. Pressing an item in the feed navigates to a details page, which is another screen in the stack, navigation.goBack() resets the tab position.

@satya164 satya164 transferred this issue from react-navigation/react-navigation Jun 11, 2020
@florian-milky
Copy link
Author

florian-milky commented Jun 12, 2020

I found a workaround which is to put your screen in a tab navigator at the top level navigation and hide it.
See react-navigation/react-navigation#4069

@timnlupo
Copy link

I am also interested in an official workaround for this

@meshaabi
Copy link

hmm would it work as expected if you use .push instead of .navigate ?

@kpetrow
Copy link

kpetrow commented Jun 9, 2021

taken me round 6 hours to find this thread... Is there any solution?

@kpetrow
Copy link

kpetrow commented Jul 13, 2021

BUMP. I was able to use a couple workarounds but now need some more nesting that keeps resetting the state of my webview when i navigate back to it. Would be really nice to get a solution to this

@phazei
Copy link

phazei commented May 2, 2025

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants