$ git show count-up

Number count-up

Basic/anim count-up

Count a number up from 0 to its value, for stats, balances and scores.

Main · New Architecture only · worklets live in react-native-worklets

This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.

useAnimatedPropswithTimingTextInput text prop
count-up.tsx · reanimated 4
// Text can't be animated on the UI thread, so animate a read-only TextInput's text prop
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);

const value = useSharedValue(0);
useEffect(() => {
  value.value = withTiming(1280, { duration: 1200, easing: Easing.out(Easing.cubic) });
}, []);

const animatedProps = useAnimatedProps(() => {
  const text = Math.round(value.value).toString();
  return { text, defaultValue: text } as any;
});

<AnimatedTextInput
  editable={false}
  underlineColorAndroid="transparent"
  animatedProps={animatedProps}
  style={styles.number} // add fontVariant: ['tabular-nums'] so digits don't jiggle
/>