React Native - Stack Navigator, close multiple views

I am trying to close multiple views in Stack Navigator without ugly animation. The application structure looks like this:

Tab navigator:

  • Screen 1
  • Screen 2
  • Screen 3

StackNavigator:

  • Tab navigator (route name: Home) => Registration type => Entry type

Figure 2 shows a button that opens the registration view in the Stack Navigator, and from the registration window, you can open the login window.

When I login, I want to dismiss the registration and registration view and return to Screen 2 using just one animation.

I've tried with this:

NavigationActions.reset({
    index: 0,
    actions: [
        NavigationActions.navigate({ routeName: 'Home' }),
    ],
})

      

as I saw in a similar question, but this is not the expected behavior. With this code, we can see how the two views (login and registration) fire the animation sequentially and the Tab Navigator returns to screen 1.

I've tried with too NavigationsActions.back

, but nothing happens when I set the parameter ({key: 'Home'})

(I've tried using Home, RegistrationView and the "key" value found in the navigatorState routes).

How can I make it right? Hope you can help me, thanks.

+3


source to share





All Articles