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
DrawerNavigator screen shouldn't unmount #2277
Comments
why do you not call |
@vonovak because I don't want to rerender my screen when I press the Drawer. In the mean time nobody has answered or helped me out I started to dig and search for a solution to my problem. Now I have a kind of solution but it seems not to work so I created a detailed new issue with my newest try at #2495 As this is not longer a problem for me, because I found a kind of workaround, the issue can be closed. But I'm still interested in finding a solution or the answer that is is an antipattern or something like this |
@vanBrunneren my guess would be that goBack() does not cause a re-render, but I have not tested it |
@vonovak oh sorry I was i bit confused at the moment. Of course you are right goBack() does not a rerender. But I have multiple routes in my stack and I want to jump maybe from the 6th to the 3th and this is not realizable with a goBack(). And If I do a goBack() the route which I press goBack() on will get unmounted. And when I go from maybe the 5th route to the 7th and then switch again to the 5th the 5th would be unmounted and has to mount again. This is not what I want, I want a function like "jumpTo" where you can jump to the routes in the stack |
+1 |
Pinging OP @vanBrunneren 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. |
Ok, thanks for letting me know.
Maybe you are the only ones trying to achieve this without a state manager (redux or MobX)?
Can't really tell atm. The Drawer is a "portion" of the navigation I personally don't use so I don't have much knowledge of best practices (I know @GantMan was writing some articles/tutorials which you can find linked in the README); and I think this issue, in particular, seems quite "low priority" in the grand scheme. But nothing is set in stone. |
@vanBrunneren Did you manage to find a simple solution for the Drawer nav problem ? I am facing the same issue and it is really irritating when there is no straight solution for a problem like this ... |
@amirmatin no not at the moment, I didn't had the time at the moment to work on this, as soon as I have more time I definitely give this another effort |
@vanBrunneren thanks for your comment.. I am giving this other lib called "react native navigation" a shot and will let you know if I had any luck .. from their example it seems that they don't have the re-mounting issue .. |
+1. I would also like to see this implemented. If you have a very 'heavy' screen, you shouldn't be forced to re-render it every time. |
@Jaftem I am using this other lib called "react native navigation" which doesnt have this issue.. It has less documentation but the example they provide is really all you would need .. |
Guys, I found solution how do not unmount. First of all StackNavigator must be in DrawerNavigator. At this point changing screens from DrawerNavigator it not run componentWillUnmount method. `Example
` At this point going back it keeps previous screen. But you should know it re runs constructor, componentWillMount and componentDidMount methods when selected screen from menu. When loads menu and to header shows <- back arrow. When you click it - runs componentWillUnmount on active scrren and it is not more available to load prevous state. More abount navigation actions can read at: https://reactnavigation.org/docs/navigators/navigation-actions `SideMenu
` I think it helps for someone :) |
I have also ran into this issue and it's a pain. I swapped over to react-native-navigation as suggested by @amirmatin and it initially worked well. However I ran into a bunch of limitations/bugs with that component and I am therefore hoping that there will soon be a fix to the unmount problem in react-navigation so I can go back to using it. |
I agree this behavior should not be the default for drawer.. I think it should work just like tabs. |
possibly (?) related: #3164 |
@brentvatne Do you know if this is going to be addressed to work just like tabs? And if so, is there any timeline for when it might be looked at? Thx! |
@brentvatne Please add an option to toggle between the two behaviors instead of replacing the current behavior entirely. |
@jaltin - not until after we release 2.0. you could fork drawernavigator and make your own version though, eg: https://github.com/react-europe/react-europe-2018-mobile/blob/master/src/Navigation.js |
Thanks for the update @brentvatne. Do you have any idea of how long it might be before 2.0 is released? |
maybe next week but anyways if you need this now you should just make your own drawer navigator |
So, since the drawer goBack() is broken / no working as intended, I've tried to find a work around. Here it is, combining drawerNavigator and StackNavigator:
This solution is quite easy to implement. I'm using react-navigation @brentvatne Do you validate this kind of use or is it not intended and will be fixed in the future? Here's a working Snack |
moved this issue to new repo https://github.com/react-navigation/react-navigation-drawer/issues/4 |
Hi at all, maybe it's a misunderstanding or just my fault but I googled for hours, I made a StackOverflow post and I wrote on Discord but no one seems to have a solution to my problem.
Current Behavior
I built a very simple example which shows my problem. I have a DrawerNavigator with 2 Screens
My steps:
Expected Behavior
I'm expecting the HomeView should stay mounted. If I'm calling
this.props.navigation.navigate('HomeView')
I'm expecting my app should show the HomeView Screen as I had it before leaving it. Am I the only one who's facing this issue? Or is my concept completely wrong and someone can tell me a better way to do this? This is a very basic example but think of I'm having a Drawer and each object is a StackNavigator with multiple subroutes. Consider to go navigate 3 times in the first stack, then call another Route from the Drawer and then going back to the first route. You don't want to rerender the whole Stack....I'm lucky with any suggestions because I'm getting tired of try and fail
Your Environment
The text was updated successfully, but these errors were encountered: