0

My route structure is as Follows

- StackNavigator
  -- SplaceScreen
  -- LoginScreen
  -- HomeScreen (Drawer Navigator)
    --- Listing Screen (Stack Navigator)(Default Screen that loads)
    --- Booking Screen (Stack Navigator)
    --- Profile Screen (Stack Navigator)

Expected Behaviour

Now when i navigate to Booking screen From Listing screen, I want to replace Listing screen with Booking Screen (e.i when i press back on Android I dont want to see Listing screen)

Current Behaviour

Booking screen is adding above Listing screen (e.i it is not replacing)

Solution Tried

 const resetAction = StackActions.reset({
                index: 0,
                key:null,
                actions: [NavigationActions.navigate({ routeName: 'BookingScreen' })],
            });
            props.navigation.dispatch(resetAction)

Error Received

There is no route defined for Key BookingScreen. Must be one of 'SplashScreen,LoginScreen,HomeScreen'

So how to reset inner stack

VjLxmi
  • 400
  • 1
  • 4
  • 17

1 Answers1

0

You can use replace will replace the current route in the stack:

 StackActions.replace('BookingScreen')

you will not be able to back to the replaced route.

Taym95
  • 2,331
  • 13
  • 14