React-spring: React Native transform issue on 9.0.0-rc.2

Created on 8 May 2020  路  7Comments  路  Source: pmndrs/react-spring

馃悰 Bug Report

I'm attempting to animate the transform property of a View in RN with a useTransition hook. It crashes on runtime with the invariant violation shown below.

It's possible this is user error - but if so, I'm totally stuck, having tried multiple versions of spring & RN to no avail.

// Am I importing these correctly? 
import {animated, useTransition} from "react-spring/native"

const MyComponent = () => {

  const [s, set] = useState(false)

  // Using the new API, hopefully correctly
  const transition = useTransition(s, {
    native: true,
    from: {translateY: 80},
    enter: {translateY: 0},
  })

  return (
      <View>
                {transition(({translateY}, item) => {
                    return (
                      <animated.View style={{transform: [{translateY}]}}>
                           <Text> It worked! </Text>
                      </animated.View>
                    )
                  })}
      </View> 
  )
}

This is the error I receive:

IMG_45E9DDAF39A9-1

Minimal Repro: https://github.com/piazz/react-native-spring-issue

I'm a huge fan of react-spring and hoping to use this successfully on RN. Thanks for the help!

Environment

  • react-spring v9.0.0-rc2
  • react-native v0.61
bug react-native regression v9

All 7 comments

Please setup a git repository with a minimal reproduction. Thanks! 馃憤

Side note: You don't need native: true anymore. That's the default

edit: Actually, I don't think native: true was ever supported for React Native.

Repro here: https://github.com/piazz/react-native-spring-issue

Interestingly, in this case I'm getting a new error: unrecognized selector
Screen Shot 2020-05-08 at 3 33 52 PM

FWIW, the reason I thought I had to pass native: true was due to this post from Paul: https://github.com/react-spring/react-spring/issues/518#issuecomment-461612569
Looks like he wasn't referencing RN though, so my mistake.

I'm seeing this in my own project. Looking into it.

I see that you put out a commit to fix this - can I try it out and close out this issue? Is there a dev branch I can pull from or something?

Appreciate the quick work 馃敟

Use the v9 branch and see the CONTRIBUTING.md file for setup instructions. 馃憤

I will publish the fix tomorrow. I'm waiting for a change in react-three-fiber to be published.

Fixed in 9.0.0-rc.3

Was this page helpful?
0 / 5 - 0 ratings