there is small part of my code throwing error on some of devices with possible solutions:
a) If you want to synchronously execute, mark it as a Worklet
b) If you want to execute this method on JS thread, wrap it using runOnJS.
Error appear only on certain devices.
const movingStyle = useAnimatedStyle(() => {
'worklet';
return {
transform: [
{
translateX: withSpring(translateX.value, {
damping: 10,
restSpeedThreshold: 5,
}),
},
],
};
});
return (
<PanGestureHandler onGestureEvent={swipeGestureHandler}>
<Animated.View style={[movingStyle, styles.profilecontainer]}>
<ImageBackground> ... </ImageBackground>
</Animated.View>
</PanGestureHandler>
);
I tried to wrap it into runOnJS or use Worklet, but none of them worked for me.
I would be grateful for help.