-
-
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
goBack() additional functionality #905
goBack() additional functionality #905
Conversation
…:gorokhovich/react-navigation into feature/goback-functionality
What Maybe rename |
@Kerumen I would say that Waiting for this to be merged 👍 |
@alimek And what |
It makes sense to add a 'goToTop' action to satisfy the use case you mentioned. I really think the key is enough for most back actions. When a screen fires an action to go back two 'pages', how does the screen know how far the destination screen is? If you add a new screen in the middle of your flow, your final screen will only go back a certain amount, and won't go back all the way. I think the current API is nice because it encourages you to decouple your screens. If you have a more complicated navigation behavior, it may make sense to customize the router and add your own navigation actions. The issue with ScenesReducer is interesting, and I think your approach makes sense, even if the code is super confusing. Basically what you're doing is to only render one stale scene (the one that was on top), rather than all of the stale scenes. Can you submit this in a separate PR, and make the variable names a bit more specific? |
@Kerumen |
@ericvicenti this PR came from needs of my project. We were migrating from RN Navigator to this one. We had lots of popN and popToTop functionality. There were no such functions in react-navigation so that's why I added it by myself. re: ScenesReducer. Sure I can and will, but current solution looks hacky :) I would like to go deeper and maybe change it to more robust and cleaner solution. |
@ericvicenti how exactly is the current api help with decoupling, when we need to pass the key of the screen to go back from? are you serious? you and @grabbou, and the rest of the main committers/maintainers are all handing this library like its your personal thing, and you are being proud that its featured in many places online, and your just resting on your laurels. the last like 6 months, this project had no real change. there are so many issues of missing features and so many prs that should be merged, and the response to most of them is "this is not needed." (no explanation), or "i like it the way it is now.", or whatever else. please please, allow people to help you, or move it away. thank you. |
Sorry about the troubles you're experiencing with the library. This is a large project and isn't very easy to organize. Everybody needs different features and the library is designed to allow you to override and customize things as you need. And if you really do need to fork it for your organization, go right ahead! I'm happy to review PRs but I think we need to be careful about adding a bazillion features that will make the library even harder to maintain than it is today. cc @skevy who is spending more time on it and is also interested in keeping it simple and maintainable.
Say you want to build a portable modal that can be dropped into many apps. The modal has a 'close' button, and when you press it, you want to go back. If you For this issue, I think we should support If you have specific suggestions or requests regarding community management, feel free to open up another issue to discuss it! We're absolutely interested in doing better. |
i have forked to try and fix a couple of things, but forking is not the solution always. about the modal: the modal would just call the this is also a thing im sure can be better. consistency of this project. things are all over the place. you have indexes, but they are not visible in the |
Jeez, if you say so. Push and pop work great for a simple stack, but we're trying to find a set of actions that can navigate a tree of routes. Thats why You're probably right that things could be more consistent. Do you have any actionable ideas on how it can be improved? |
i made this new issue so we can talk about some stuff there. and i dont mean it in a bad way, dont get me wrong, but in my experience, when you try to have one method for those functionalities, it either doesnt work in the end, or its just a huge monster that could be split to smaller parts. push and pop work fine for a tree of routes, because in the end, its is a simple stack. the screens are a big tree, but the screens the app followed at any point, is just a simple stack of screens (tree nodes). its just pointing to them. |
@pvinis - I wasted a bunch of time trying to integrate this navigator into a large project and am not surprised to see so many PRs and fixes going ignored or being glibly rejected. Why is anybody using and trying to contribute to this as opposed to aksonov/react-native-router-flux? I don't understand, is every package just inadequate right now? How is anyone shipping RN projects with complex navigation, let alone something that needs to use basic back functionality? There should be a big "UNSUITABLE FOR PRODUCTION PROJECTS" on the homepage instead of a nicely designed website. |
@ericvicenti when will the pr be published as a release version? |
@jameskhamil - the reason i moved to react-navigation from react-native-router-flux, was that i liked the fact that each screen was customized in the screen's component. so basically before i had all the navigation options in the big nav file with all the screens, and now i have them on each screen component. to me, it makes sense. |
@ALL so at now ,how do we realize popToRoot likes iOS platform: popToRootViewController ? Without the splash of the middle screen? |
+1 !!!!! |
@ericvicenti as a developer, i really really want pay not so much attention to how i deal with the routers. i hope i can care more about my own works, rather how i get the key, pass the key, then i can jump the key screen. You think routerName is same to key. But i'd like to use goBack(LogPage) rather than goBack({key: 'id-14764567767678-11'}), right? To me, react navigation is a tool to deal with router. As a tool, its API should adapt to more situation directly. |
Gawd this is really really awful. I've wasted countless hours on this junk navigation, keep it simple guys..
What am I to do? The documentation is useless and usually outdated. |
I don't know that why they ignored this issue. navigation.goBack(); is useless to go back N pages. |
@voidstarfire the way to get the key of screen(named ScreenA) is from the state like this |
@ranran2 lol, that doesn't even work... and the first thing you're probably going to say, is that I'm not doing it right (the proper context of this.proper.navigation is lost whenever it's accessed from child components not registered as screens) this "popToTop" kind of feature is not an edge case... the most common use case for needing this "popToTop" feature, is when a user logs out of the app... in fact, "popToTop" is not even a good solution for this, especially if you need your root component/index/screen to be re-rendered... NavigationActions.reset is the only thing that comes close, but unfortunately since the routeName is scoped to the current sub-stack and not the root/parent stack, 'reset' cannot solve this common use case either a goBack() method (one that actually works globally across the app) has it's proper use cases, but logging a user out is not one of them... for a proper logout function, 'this.props.navigation.goBack(screenKey)' is not the correct way to do this since it navigates/pops you to an already mounted component as opposed to the expected/intended "reset then push" pattern |
The reset functionality also comes with a nasty animation of 'all the screens'! woot... The custom transitions are complicated as hell to work out. |
Aw jeez, this is all just a mess... (-_-) |
so the goBack functionality is still NOT merged ? |
@quadsurf you can pass the navigation to child component. i use this in my project and it works.lol |
Are you guys still maintaining this library? It seems like there's some major work to be done and people willing to do it, but they need to be given access. I think there are a lot of people building production apps around this library and it would be great if fixes could be applied for the bugs found. Go back is especially hard to deal with. |
Any updates? |
Is it possible to work on the |
I and many other people meet lack of base functionality provided by RN Navigator such as
.popToTop
and.popN()
.This pull request add such functionality by modifying input params for
.goBack()
Now it accepts such objects:
.goBack({ key: 'your-route-key' })
.goBack({ numberOfPages: 3 })
- goes backnumberOfPages
screens.goBack({ routeName: 'YourRouteName' })
- goes back to the screen in stack with suchrouteName
.Adding these stuff other issued popped -- when moving back few screens previous screens are flashing.
I added work around, but would like to hear a solid solution to fix that before merging PR
. This requires tests to be fixed.Now I use these branch and these functions on my own production project and it works perfectly!