So I have an animation using React Native Reanimated
that repeats every 3 seconds and updates the SharedValue
. I have implemented it as shown below using setInterval
.
const SomeThreshold = 5;
useEffect(() => {
progress.value = 0;
const interval = setInterval(() => {
if (progress.value === SomeThreshold) {
progress.value = 0;
return;
}
progress.value = withTiming(progress.value + 1, {
duration: 2000,
});
}, 3000);
return () => clearInterval(interval);
}, []);
What I want to achieve is
-> Animation Starts
-> Progress = 1
-> Progress = 2
-> Progress = 3
-> Progress = 4
-> Progress = 5
-> Progress = 1
-> Progress = 2
and this goes on infinitely.
Is there any way to implement it without using Web APIs like setInterval and maybe using withRepeat
.