question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning - Method `repeat` is deprecated. Please use `withRepeat` instead

See original GitHub issue

Description

I’m following the example to use the withRepeat hook, but getting a warning.

Screenshots

Steps To Reproduce

Code below

Expected behavior

Animation runs as expected, and repeats indefinitely. No crashes.

Actual behavior

Warning when animation starts. Crash when animation finishes.

Snack or minimal code example

const ANGLE = 2;
const DURATION = 120;
const EASING = Easing.inOut(Easing.ease);

const AnimatedSmartGridTile = (props: SmartGridTileProps) => {
  const smartGridContext = useSmartGridContext();
  const editing = smartGridContext.editing;

  const rotation = useSharedValue(0);
  rotation.value = editing.value
    ? withSequence(
        // deviate left to start from -ANGLE
        withTiming(-ANGLE, {duration: DURATION / 2, easing: EASING}),
        // wobble between -ANGLE and ANGLE 7 times
        withRepeat(
          withTiming(ANGLE, {
            duration: DURATION,
            easing: EASING,
          }),
          -1,
          true,
        ),
        // go back to 0 at the end
        withTiming(0, {duration: DURATION / 2, easing: EASING}),
      )
    : 0;

  const animatedStyle = useAnimatedStyle(() => ({
    transform: [{rotateZ: `${rotation.value}deg`}],
  }));

  return (
    <Animated.View style={animatedStyle}>
      <SmartGridTile {...props} />
    </Animated.View>
  );
};

Package versions

  • React: 16.13.1
  • React Native: 0.63.3
  • React Native Reanimated: 2.0.0-alpha.8
  • NodeJS: 12.18.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bhaskarmurthycommented, Nov 10, 2020

I’m actually using withRepeat - code snippet below:

rotation.value = editing.value
    ? withSequence(
        // deviate left to start from -ANGLE
        withTiming(-ANGLE, {duration: DURATION / 2, easing: EASING}),
        // wobble between -ANGLE and ANGLE 7 times
        withRepeat(
          withTiming(ANGLE, {
            duration: DURATION,
            easing: EASING,
          }),
          -1,
          true,
        ),
        // go back to 0 at the end
        withTiming(0, {duration: DURATION / 2, easing: EASING}),
      )
    : 0;

Crash is not happening - it was not related to this issue.

0reactions
piaskowykcommented, Nov 10, 2020

Ok, thanks for information. Good luck!

Read more comments on GitHub >

github_iconTop Results From Across the Web

withRepeat | React Native Reanimated - Software Mansion
This function will be called when all repetitions of the provided animation are complete or when withRepeat is cancelled. In case the animation...
Read more >
Using UIViewPropertyAnimator with repeat and autoreverse ...
Is there any possible way to autoreverse and repeat a property animation without having to use deprecated code? Please do not suggest to...
Read more >
Intermediate R for Finance - RPubs
Repeat, repeat, repeat. Loops are a core concept in programming. They are used in almost every language. In R, there is another way...
Read more >
Intermediate to R for Finance - Amazon AWS
POSIXct is a way to represent datetime objects like “2015-01-22 08:39:40 EST”, meaning that ... Argument ohlc_fun is deprecated; please use select instead....
Read more >
Frequently Asked Questions about Pardot - Salesforce Help
An error reading 'WARNING: Your Salesforce Connector user does not have all ... to repeat rule' counted in the automation rule with 'Repeat...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found