React-native-reanimated: Repeat doesn't behave like withTiming

Created on 24 Aug 2020  路  5Comments  路  Source: software-mansion/react-native-reanimated

The following example works:

const progress = useDerivedValue(() => withTiming(1));

The following crashes:

const progress = useDerivedValue(() => repeat(withTiming(1), -1, true));

I'm trying to achieve maximum composability between between animations and would like to write the following:

const paused = useSharedValue(false);
const progress = useDerivedValue(() => withPause(repeat(withTiming(1), -1, true)), paused);
馃彔 Reanimated2 馃悶 Bug

All 5 comments

I also have a concern about the boilerplate required to build custom animations. While I was able to build a custom animation outside reanimated 2, animations defined in animation.js seem to use boilerplate that might be useful to other animations (namely defineAnimation())

@wcandillon does this problem still occur? I just tried it out and it worked just fine, can you confirm?

Thanks for following up on this, closing it.

I can confirm that the behaviour still happens:

  const progress = useSharedValue(0);
  useLayoutEffect(() => {
    progress.value = repeat(withTiming(1, {duration: 400}), -1, true);
  }, [progress.value]);

Closing again, looks this has been fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjartebore picture bjartebore  路  3Comments

sa8ab picture sa8ab  路  3Comments

levibuzolic picture levibuzolic  路  3Comments

dinhmai74 picture dinhmai74  路  3Comments

mrousavy picture mrousavy  路  3Comments