0

I have a react native app and following is the screen flow-

Splash screen -> login -> FlightList

When I am in flightlist screen, I press back button and it takes me back to splash screen.

I want to exit the app when I press back button in flight screen. I saw some code here NavigationActions.reset is not a function?

import { NavigationActions, StackActions } from 'react-navigation'
const resetAction = StackActions.reset({
    index: 0,
    key: null, // <-- this
    actions: [NavigationActions.navigate({ routeName: route })]
})
this.props.navigation.dispatch(resetAction)

But I am not sure where should I use it. Could any one help me with this please

1 Answers1

0

You could use it anywhere. In your case if you use it in Login your stack will change from Splashscreen->Login->FlightList to FlightList and i suppose route is equal to the name of your FlighList in your StackNavigator.

mcssym
  • 956
  • 5
  • 8