Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withRepeat using array will not reverse #6799

Open
odogono opened this issue Dec 9, 2024 · 0 comments
Open

withRepeat using array will not reverse #6799

odogono opened this issue Dec 9, 2024 · 0 comments
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@odogono
Copy link
Contributor

odogono commented Dec 9, 2024

Description

A shared value which contains a number array will not behave as expected with a withRepeat hook.

If the parameters of the withRepeat hook are set to reverse, the sharedValue will increment to the desired value correctly, but then instead of reversing back to the original value, it will remain.

I have checked the behaviour with object ( {x:0} ) and number values, and they behave as expected.

I did some limited debugging, and I observe that the repeat animation.startValue is referentially the same as the nextAnimation.current when an array is used during the "forward" part of the animation, but when an object or a number is used the value reference is different (within /packages/react-native-reanimated/src/animation/repeat.ts)

Steps to reproduce

  1. create a shared value containing a number array
const arrayValue = useSharedValue([0]);
  1. set up a repeated timing
arrayValue.value = withRepeat(
      withTiming([30], { duration: 1000 } ),
      2,
      true);
  1. Observe the value changing
useAnimatedReaction(
  () => arrayValue.value,
  (value) => {
        console.log('value', value);
   }
);

Snack or a link to a repository

https://snack.expo.dev/@odogono/uplifting-green-waffles

Reanimated version

3.16.3

React Native version

0.76.3

Platforms

Android, iOS

JavaScript runtime

None

Workflow

None

Architecture

Fabric (New Architecture)

Build type

None

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Dec 9, 2024
@odogono odogono changed the title withRepeat using array will not reverse withRepeat using array will not reverse Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

No branches or pull requests

1 participant