-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Don't render twice when goBack and re navigate on same screen #2331
Comments
Here's a snack to go along with this. I'm not sure why you would want the behavior you described as going back would imply you're not longer interested in that screen. I also imagine it would add a host of issues with tracking navigation state (what happens when you go from screen 1 to screen 2, back to screen 1, then to screen 3 - does screen 2 get unmounted?) |
@spencercarli |
@sseyha ah that makes complete sense! Hadn't thought about that - thanks for clarifying. I'm typically using Redux so in cases like this I would have saved the data to the store after the first screen mount and then any subsequent screen mounts would use the old data and refresh in the background. |
@spencercarli |
I don't have any small examples directly related to this but you can see this strategy in action in this repo. That repo is broken down into a bunch of branches (it's for a course) but the final app can be found on the module-7-lesson-4-upload branch. |
@spencercarli I will learn more about redux. However, Thank so much for your guide. Appreciate! |
Thanks for your answers. Like @sseyha said, I don't want to reload the component again and again, but my problem with the reloading isn't about reloading any data (effectively stored in redux) but is to reload a few GLView components that take time to render. |
Ah, I see. I'm not sure of a solution to this issue. I suppose I've seen a similar issue when pushing a screen with a map onto the stack. I'll do some thinking and if I can think of anything useful I'll try to add it to this thread. |
@spencercarli You how to refresh or reload the current active page of drawer? |
related i guess : #2365 |
+1 |
+1 , don't want to reload the component again and again when re-enter the screen. Hope there have a solution for this. Because I also finding solution Close screen / unmount screen |
Pinging OP @thomasarbona since this issue has not been active for a while, and it's related to an old version of the lib. Please let me know if you want this to remain open; if I get no answer in the next 7 days I will close it. Moreover:
This is literally the way a stack is supposed to work. If there are data you need to manage/show in the second screen, you need to use a state manager like Redux. Or you could use a tab navigator without showing the tabbar. |
Hi there @thomasarbona , In an effort to cleanup this project and prioritize a bit, since this issue had no follow up since my last comment I'm going to close it. If you are still having the issue with the latest version (especially if it's a bug report) please check the current open issues, and if you can't find a duplicate, open a new one that uses the new Issue Template to provide some more details to help us solve it. |
To the above posters that want to reload the content data, you can create a function which resets the data to their original state. An example is as follows:
|
Hello! Someone found a solution? |
I use StackNavigator for a small application with some screens.
Current Behavior
When I am on screen B, goBack on screen A (B was unmount) and re navigate on B, B is re-mount.
Expected Behavior
I expect that the StackNavigator keep screen B mount so when I re navigate on B it don't render it twice.
How to do that ? Should I navigate without goBack ? (I use fade transition)
Your Environment
The text was updated successfully, but these errors were encountered: