react-navigation-shared-element: [v5] Nested navigators (Tab Navigation) breaks navigation
Firstly, great library and thanks for the work.
Trying out the 0.7.0-alpha0 with React-Navigation 5, nested navigators, is in a Tab-Navigator breaks navigation completely within the stack. have included a video below. When I do not nest the navigator within the tab navigator and just use a stack navigator, the animations work fine and the navigation.navigate fires as expected. When nested within a Tab, it just causes a re-render of the component in which the function is called. This problem persists in both android and ios
https://drive.google.com/open?id=1MoMhtNSYOjq0yDNC-QvjQQ4Q-6TSPlfF
Here is the stack and tab navigators I’m using in the video.
const SearchStack= () => {
const { Navigator, Screen } = createSharedElementStackNavigator<SearchParamsList>();
return (
<Navigator
initialRouteName="search"
headerMode="none"
mode="modal"
screenOptions={{
cardStyleInterpolator: ({ current: { progress } }) => {
const opacity = progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
extrapolate: 'clamp',
});
return { cardStyle: { opacity, backgroundColor: 'white' } };
},
}}
>
<Screen
name="search"
component={FetchProducts}
initialParams={{ listType: 'search' }}
/>
<Screen
name="product"
component={Product}
sharedElementsConfig={(route, otherRoute, showing) => {
if (typeof route.params !== 'undefined') {
const { product } = route.params;
return [`image.${product._id}`, `background.${product._id}`];
}
return [];
}}
/>
<Screen name="ProductShops" component={ShopMap} />
<Screen name="ProductSimilar" component={FetchSimilar} />
</Navigator>
);
};
const AppRoutes = () => {
const Tab = createBottomTabNavigator<TabParamsList>();
return (
<Tab.Navigator
initialRouteName="Search"
tabBar={(props) => <BottomNavigation {...props} />}
>
<Tab.Screen
name="Search"
component={SearchStack}
initialParams={{ listType: 'search' }}
/>
{/* <Tab.Screen
name='Suggestions'
component={Search}
initialParams={{ listType: 'search' }}
/>
<Tab.Screen
name='Tastings'
component={Search}
initialParams={{ listType: 'search' }}
/> */}
<Tab.Screen name="NewTasting" component={NewTastingStack} />
</Tab.Navigator>
);
};
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 15 (3 by maintainers)
SOLVING THIS PROBLEM FROM COMMENT @IronTony : In to Tab screen component add this:
instead :
UPD: remove
because it call bugs to return to previous screen after navigation to next shared screen!!!