Closed brentvatne closed 4 years ago
Maybe navigation.canGoBack()
is better, similar to history.canGoBack()
? The method navigation.isFirstRoute()
is only useful for stack navigator, in other navigators you might want different behavior, for example, to treat the initial route as the first one in history. Also not sure how it would work with nested navigators, where even if a route is the first one, it might be nested in another one, so you can still go back. Since we don't have access to the parent's state, we can't handle it properly.
that's a neat idea!
Yup I think this is very useful. I am doing some nasty checks right now. I am working in a native app that includes some screens with RN and react-navigation. When we are in the first screen of RN, we need to know it so we can cal some native method or enable/disable swipe iOS gestures.
Closing since isFirstRouteInParent
API was added.
Should be available on
navigation
, likeisFocused
:navigation.isFirstRoute()
or something like that. This is useful if you want to add a custom back button and perhaps other things as well.