IjzerenHein / react-native-shared-element

Native shared element transition "primitives" for react-native 💫
MIT License
2.21k stars 97 forks source link

createSharedElementStackNavigator nested inside BottomTabNavigator from react-navigation #52

Closed VictorioMolina closed 3 years ago

VictorioMolina commented 3 years ago

I have a stack, which is created with "createSharedElementStackNavigator" inside a tab navigator from react-navigation-5

Previously, I was using the default stacks provided by react-navigation-5, but now, as I need to create a shared transition, I have replaced it.

Before, the default behaviour when pressing an active tab (which content is a stack) was to:

 1. Pop to the top of the stack navigator
 2.  Scroll to the top if 1 wasn't impossible because there is only 1 active stack screen

Now, with createSharedElementStackNavigator, nothing happens when I press the tab from my TabNavigator.

Is it possible to reach this same behaviour with this library?

VictorioMolina commented 3 years ago

Solved with:

       <Tab.Screen
            name="Profile"
            component={ProfileStacks}
            listeners={({ navigation, route }) => ({
              tabPress: () => {
                if (route.state?.routes.length > 1) {
                  navigation.popToTop();
                }
              },
            })}
         />