react-navigation / rfcs

RFCs for changes to React Navigation
Other
88 stars 16 forks source link

Helper to determine if first screen in routes #57

Closed brentvatne closed 4 years ago

brentvatne commented 6 years ago

Should be available on navigation, like isFocused: navigation.isFirstRoute() or something like that. This is useful if you want to add a custom back button and perhaps other things as well.

satya164 commented 6 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.

brentvatne commented 6 years ago

that's a neat idea!

ferrannp commented 5 years ago

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.

satya164 commented 4 years ago

Closing since isFirstRouteInParent API was added.