-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Description
Animating color transitions with Animated API causes issues. Depending on what type of component is used, the issue is different:
- When using native components, e.g.
Animated.Viewthe color is flickering instead of smoothly animating (see square box in the code example). - When using a custom component wrapped with
Animated.createAnimatedComponent()the issue is related to state persistence (see pin icons in the code example). It seems like the color change is applied after another state change occurs in the parent component.
See screen recording for details. The recording comes from an Android simulator but I can confirm the issue also appears on an iOS simulator and a real Android device. I can also confirm that the problem cannot be related to the Expo Go app itself as I discovered the problem originally in my own app which runs on Expo v54 and react-native v0.81.5, run on both iOS/Android emulators/devices from development builds.
Link to the reproducible Snack: https://snack.expo.dev/@matewka/animated-api-test
In the provided example I've added two pin icons from two separate packages (one from @expo/vector-icons, one from react-native-svg) to eliminate the possibility of a 3rd party library causing the issue.
It doesn't matter to me which library I would use by the end of the day, I just need a pin icon that can have an animated color.
Steps to reproduce
- Install the app from the provided link: https://snack.expo.dev/@matewka/animated-api-test
- Click on the square box to see the flickering color transition. The expected behaviour is a smooth transition from black to red color
- Click on one of the pin icons. You will see no difference in color. The status next to the icon will change from "off" to "on".
- Click on something else, for example the square box. This causes the state change and the entire App component to rerender. This time the pin icon is updated with the correct color.
React Native Version
0.81.5
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
The code was run in snack.expo.dev. Unable to run the command there.
Stacktrace or Logs
There are no logs.
MANDATORY Reproducer
https://snack.expo.dev/@matewka/animated-api-test
Screenshots and Videos
Screen recording: