Shared Element Transitions #150
Replies: 12 comments 8 replies
-
No, we use |
Beta Was this translation helpful? Give feedback.
-
Looks like it's way simpler than the existing Expo Shared Element example. You just use a import Animated from 'react-native-reanimated'
function Screen1({ navigation }) {
return (
<View style={{ flex: 1 }}>
<Animated.View
style={{ width: 150, height: 150, backgroundColor: 'green' }}
sharedTransitionTag="sharedTag"
/>
<Button title="Screen2" onPress={() => router.push('/screen2')} />
</View>
);
}
function Screen2({ navigation }) {
return (
<View style={{ flex: 1, marginTop: 50 }}>
<Animated.View
style={{ width: 100, height: 100, backgroundColor: 'green' }}
sharedTransitionTag="sharedTag"
/>
<Button title="Screen1" onPress={() => router.push('/screen1')} />
</View>
);
} |
Beta Was this translation helpful? Give feedback.
-
@ThatGuySam import Animated from "react-native-reanimated";
import { router } from "expo-router";
const { width } = Dimensions.get("window");
const ScreenA = () => {
return (
<View style={styles.container}>
<Animated.View
style={styles.sharedContainerA}
sharedTransitionTag="tagger"
>
<Text style={styles.textStyleA}>Hello world</Text>
</Animated.View>
<TouchableOpacity
onPress={() => {
router.push("/shared_element/shared_component_b");
}}
>
<Text>Go to B</Text>
</TouchableOpacity>
</View>
);
};
export default ScreenA;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
sharedContainerA: {
width: width * 0.6,
height: 400,
justifyContent: "center",
alignItems: "center",
backgroundColor: "tomato",
},
textStyleA: {
fontSize: 18,
fontWeight: "300",
},
});
// Screen B
import Animated from "react-native-reanimated";
const { width } = Dimensions.get("window");
const ScreenB = () => {
return (
<View style={styles.container}>
<Animated.View
style={styles.sharedContainerB}
sharedTransitionTag="tagger"
>
<Text style={styles.textStyleB}>Hello world</Text>
</Animated.View>
<Link
href={{
pathname: "/shared_element",
}}
>
Back
</Link>
<Text>SharedComponents</Text>
</View>
);
};
export default ScreenB;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "flex-start",
alignItems: "center",
},
sharedContainerB: {
width: width * 0.9,
height: 600,
justifyContent: "center",
alignItems: "center",
backgroundColor: "tomato",
},
textStyleB: {
fontSize: 22,
fontWeight: "300",
},
});
```ts |
Beta Was this translation helpful? Give feedback.
-
Any update on this? Kinda nuts that we can't do this in Expo, it's such a standard feature of apps nowadays. |
Beta Was this translation helpful? Give feedback.
-
Any updates? Looking forward for this functionality |
Beta Was this translation helpful? Give feedback.
-
Yeah, it's not working for me either anymore. I tried it here with Expo 51 for anyone who wants to take a crack at it: I think the issue might be that it needs to be the same "Stack" or "Navigator" Here's the docs for doing it with React Navigation, which Expo Router uses under the hood: There's some disconnect between the expected React Navigation implementation and Expo Router. |
Beta Was this translation helpful? Give feedback.
-
Any updates on this? hopefully this feature is coming soon. |
Beta Was this translation helpful? Give feedback.
-
Also very interested in this feature. Subscribing for details. thx |
Beta Was this translation helpful? Give feedback.
-
Yup, shared transitions don't seem to work when one sits in |
Beta Was this translation helpful? Give feedback.
-
I have tried many methods, but the expo router does not support shared elements. Time: November 8, 2024 21:11:14 |
Beta Was this translation helpful? Give feedback.
-
@buildnewapp well I have it working with I am using <Animated.View sharedTransitionTag={id}> from |
Beta Was this translation helpful? Give feedback.
-
It doesn't work with the New Architecture though and the maintainer of shared elements has quit. So we have to make sure: app.json
is set going forward. |
Beta Was this translation helpful? Give feedback.
-
Are there any examples of how to do shared element transitions with expo-router?
Beta Was this translation helpful? Give feedback.
All reactions