shared element transition react native navigation code example
Example 1: react native navigation shared element
import { createSharedElementStackNavigator } from 'react-navigation-shared-element';
const stackNavigator = createSharedElementStackNavigator(
{
List: ListScreen,
Detail: DetailScreen,
},
{
initialRouteName: 'List',
}
);
const AppContainer = createAppContainer(stackNavigator);
Example 2: react native navigation shared element
const DetailScreen = (props) => {
const item = props.navigation.getParam('item');
return (
<SharedElement id={`item.${item.id}.photo`}>
<Image source={item.photoUrl} />
</SharedElement>
);
};
DetailScreen.sharedElements = (navigation, otherNavigation, showing) => {
const item = navigation.getParam('item');
return [`item.${item.id}.photo`];
};