On my app, I have buttons inside Animated Views that translate up.
Right after the translation finished, the pressable action of the button is not executed on click.
If we execute another action (ex. navigating on an other tab and come back), the pressable action is executed on click.
This is what we see on the repro below:
Additional notes:
New Arch + Android only
On real device only, not on emulator (๐ really weird)
Pressable and Buttons have the same error
Pressable and Buttons variable opacity are triggered when we click the first time; only the onPress callback is'nt triggered
On an animated view with only a variable opacity, no error; it's linked to the translation operation
Code
Code looks like this:
export const AnimatedButton = () => {
const shiftAmount = useSharedValue(-100);
const shiftDownStyle = useAnimatedStyle(() => ({
transform: [{ translateY: shiftAmount.value }],
}));
if (shiftAmount.value !== 0) {
shiftAmount.value = withTiming(0, { duration: 450 });
}
return (
<Animated.View style={shiftDownStyle}>
<Button
title="Press me"
onPress={() => Alert.alert("Im clicked")} // ๐จ not triggered the first time
/>
</Animated.View>
);
Description
On my app, I have buttons inside Animated Views that translate up. Right after the translation finished, the pressable action of the button is not executed on click. If we execute another action (ex. navigating on an other tab and come back), the pressable action is executed on click.
This is what we see on the repro below:
Additional notes:
onPress
callback is'nt triggeredCode
Code looks like this:
A full example can be found here: https://github.com/delphinebugner/repro
Further notes
Thanks for working on the lib ๐
If the problem is linked to a messy Reanimated usage in the component, happy to correct my code!
Steps to reproduce
On the repro application:
Snack or a link to a repository
https://github.com/delphinebugner/repro
Reanimated version
3.16.1
React Native version
0.75.0
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Real device
Device model
Samsung Galaxy S22
Acknowledgements
Yes