Skip to content

Animated.Value resets if not rendered #23621

Closed
@Elijen

Description

@Elijen

🐛 Bug Report

If render() method does not return an Animated.View that uses the Animated.Value we are animating the Animated.Value resets and will have a wrong value on the next render() call. This goes against the basic principle that render() method should be a pure function without side effects.

I suspect that this behavior also causes bugs/freezes when shouldRasterizeIOS set to true.

To Reproduce

  1. Animate a Value
  2. Using state show/hide the Animated.View that is using the Value periodically
  3. Animated.Value will keep reseting

Expected Behavior

Animated.Value._value should not depend on the results of render() method

Code Example

https://snack.expo.io/@peller/animated.value-bug

Environment

React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
Memory: 859.86 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.3.0 - ~/.nvm/versions/node/v8.3.0/bin/node
npm: 6.4.1 - ~/.nvm/versions/node/v8.3.0/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 26.0.1
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions