$ git show stroke-draw
Stroke draw
Draw an SVG path line by line, like a signature or logo reveal.
Inspired by Stroke animationFrom William Candillon’s “Can it be done in React Native?” series. The code here is a simplified rewrite for Reanimated 4 and 3.
This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.
import { svgPathProperties } from 'svg-path-properties';
const AnimatedPath = Animated.createAnimatedComponent(Path);
const LENGTH = new svgPathProperties(d).getTotalLength();
const p = useSharedValue(0);
useEffect(() => {
p.value = withTiming(1, { duration: 2000, easing: Easing.inOut(Easing.ease) });
}, []);
const props = useAnimatedProps(() => ({ strokeDashoffset: LENGTH * (1 - p.value) }));
return (
<Svg viewBox="0 0 120 60">
<AnimatedPath d={d} stroke="#0B7A93" strokeWidth={4} fill="none"
strokeDasharray={LENGTH} animatedProps={props} />
</Svg>
);