This example demonstrates the basic integration of react-native-shared-transition with React Navigation.
cd example
# Install dependencies
yarn install
# iOS
cd ios && bundle install && bundle exec pod install && cd ..
# Start Metro
yarn start
# Run iOS
yarn ios
# Run Android
yarn androidexample/
├── src/
│ ├── App.tsx # Entry with NavigationContainer
│ ├── assets/ # Hero images
│ ├── navigation/
│ │ ├── types.ts # Navigation types
│ │ └── RootNavigator.tsx # Stack navigator
│ ├── screens/
│ │ ├── HomeScreen.tsx # List with SharedElement
│ │ └── DetailScreen.tsx # Detail with SharedElement
│ └── types/
│ └── index.ts # Type definitions
├── ios/ # iOS native project
├── android/ # Android native project
└── ...
- Wrap elements with
<SharedElement id="...">in both screens - Use matching IDs to connect elements
- The library tracks and can animate between them
// HomeScreen.tsx
<SharedElement id={`hero.${item.id}.photo`}>
<Image source={item.photo} />
</SharedElement>
// DetailScreen.tsx
<SharedElement id={`hero.${item.id}.photo`}>
<Image source={item.photo} />
</SharedElement>