$ git show shake
Error shake
Shake an input horizontally when validation fails.
This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.
const x = useSharedValue(0);
const shake = () => {
x.value = withSequence(
withTiming(-10, { duration: 50 }),
withRepeat(withTiming(10, { duration: 100 }), 3, true),
withTiming(0, { duration: 50 }),
);
};
const style = useAnimatedStyle(() => ({ transform: [{ translateX: x.value }] }));