-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Navigator] getCurrentRoutes & willfocus/didfocus Events #2071
Comments
cc @ide |
Yep, this is a KP and we're working towards a cleaner solution. cc @hedgerwang who is going to help drive this The Navigator as we know it will own a navigation context which has a route stack. The context will emit instantaneous change events for the route stack. The navigator will subscribe to the route change events, manage animations, and coordinate gestures. |
@ericvicenti is this planned for |
Probably won't be ready for |
FYI,
I'm using const routeStackIds = this.props.navigator.state.routeStack.map((route)=> route.id);
const presentedIndex = _.indexOf(routeStackIds, this.props.route.id); |
Hi there! This issue is being closed because it has been inactive for a while. But don't worry, it will live on with ProductPains! Check out it's new home: https://productpains.com/post/react-native/navigator-getcurrentroutes-willfocusdidfocus-events |
"this.props.navigator.navigationContext.addListener('didfocus', viewAppearCallBack)" gives error "TypeError: undefined is not an object (evaluating 'this.props.navigation.addListener)" What is solution ?? |
The Issue
Navigator.getCurrentRoutes()
values are not correct in when called fromwillfocus
&didfocus
.I've implemented my own navigation bar (without the
Navigator.navigationBar
prop)I wanted to be able to toggle the back button according the current routes stack. (by using
Navigator.getCurrentRoutes()
)(any suggestions for a better solution would be welcomed)
I start the navigator with a single initial route.
pushed a new route, and from the 2nd screen I tried both:
Navigator.pop
in both cases, when I call
getCurrentRoutes
fromwillfocus
is called with 2 routes.same issue happens when using
didfocus
after going over the code I found the issue, in
_handlePanResponderRelease
https://github.com/facebook/react-native/blob/master/Libraries/CustomComponents/Navigator/Navigator.js#L659-L667
the routes stack is updated in
_cleanScenesPastIndex
but as you can see_emitWillFocus
is called before.I did noticed that the
navigator.state.presentedIndex
is the correct value.which is how it's done in the
NavigationBarSample
https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/Navigator/NavigationBarSample.js#L44-L49
and I can also check the index from the routes stack:
this seems like the wrong way to go about this...
Thoughts?
BTW, I've noticed this has some related issues:
#1252
#1346
The text was updated successfully, but these errors were encountered: