software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.05k stars 1.31k forks source link

[2.3.0-beta.4] Regression introduced in createAnimatedComponent from #2600 #2667

Closed hannojg closed 2 years ago

hannojg commented 2 years ago

Description

I've noticed a regression when upgrading from 2.3.0-beta3 to 2.3.0-beta4. We have a "count up" text animation where we use ReText from redash. Here the text prop, which is a native prop of the TextInput, is being animated.

Expected behavior

This is how the animation looks like in 2.3.0-beta3:

https://user-images.githubusercontent.com/16821682/143778598-870051af-ce41-45c4-a066-023cac0a21e0.mov

Actual behavior & steps to reproduce

This is how it looks in 2.3.0-beta4, you can see that it doesn't have the "count up" effect.

https://user-images.githubusercontent.com/16821682/143778613-abcd8527-14e9-4756-addb-db96916fe736.mov

I was able to pin down this issue to the following PR: #2600 Here, when uncommenting these lines https://github.com/software-mansion/react-native-reanimated/blob/6131585594c5f0ecf7e7832f8fb53d56210db1c8/src/createAnimatedComponent.tsx#L483-L486 everything works again. I am not too much into the reanimated code base, and just removing these lines doesn't seem like a valid fix. Maybe @tomekzaw can have another look at this?

Snack or minimal code example

Unfortunately, or interestingly, I wasn't able to reproduce that behaviour easily in a clean environment. If its necessary I can try again to provide a reproduction, please let me know.

The code roughly looks like this:

function CountUp({ value }) {
  const animatedValue = useSharedValue(value);
  const text = useDerivedValue(() => `${animatedValue.value}`, [animatedValue]);

  useEffect(() => {
    animatedValue.value = withTiming(value);
  }, [value]);

  return (<ReText text={text} />)
}

(note: Maybe #2666 is the same issue and can be used as reproduction)

Package versions

Affected platforms

github-actions[bot] commented 2 years ago

Issue validator

The issue is valid!

tomekzaw commented 2 years ago

Hello! Thanks for reporting and finding the PR that introduced this bug 🙌

Can you please check if #2668 resolves the issue?

hannojg commented 2 years ago

Yes, look good to me, thanks for the quick fix! (So with the changes in this PR everything is working again in our app 👍 )