Search code examples
react-nativereact-native-reanimatedreact-native-reanimated-v2

Repeating a repeating animation with delay with reanimated


Using react-native-reanimated, I'm trying to repeat infinitely an animation which is also a repeated animation, with a delay.

With my code, the delay and the nested repeat animation are triggered but not the inifinite one.

Any ideas ?


useEffect(() => {
  progress.value = withRepeat(
   withDelay(2000, withRepeat(withTiming(0, { duration: 500 }), 6, true)),
   -1,
   true
  );
 }, []);


Solution

  • No solution found with Reanimated, but as suggested by @Abe,a simple setInterval does the trick

     useEffect(() => {
      progress.value = withRepeat(withTiming(0, { duration: 400 }), 6, true);
      const interval = setInterval(() => {
       progress.value = withRepeat(withTiming(0, { duration: 400 }), 6, true);
      }, 6000);
      return () => clearInterval(interval);
     }, []);