Skip to content

Error when using rotation transform and "useNativeDriver: true" in Android #14161

@raulgg

Description

@raulgg

Description

Animation do not work on Android when useNativeDriver is true and using a rotation transform setting the its angle as a String value. But it works as expected when setting it in radians using a double value. I usually set the rotation using a String as it is specified in the documentation, but in this case it crashes as it is expecting a double value.

The error I am getting is the following:

error screenshot

Reproduction Steps and Sample Code

The following code sample would work either changing useNativeDriver to false or setting the rotation in radians.

  animateOpacity() {
    console.log('animation')
    Animated.timing(
      this.state.opacity_anim,
      {toValue: 1, duration: 600, useNativeDriver: true}
    ).start()
  }
  
  render() {
    return (
      <View style={styles.container}>
        {/* If the rotate transform is set in radians it works, but it doesn't when setting it in degrees with a string value. */}
        <Animated.View style={[
            styles.block,
            {
              transform: [{rotate: '90deg'}],
              opacity: this.state.opacity_anim
            }
        ]}>
          <Text style={styles.message}>Some text</Text>
        </Animated.View>
      </View>
    );
  }

I wrote an example in Expo as well: https://snack.expo.io/SJGbutsl-

Additional Information

  • React Native version: v0.44.0, v0.43.0
  • Platform: Android
  • Development Operating System: macOS 10.12.5
  • Dev tools: Android SDK 25.2.5, Android 7.0

Metadata

Metadata

Labels

Platform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions