React-spring: Unhandled Rejection (TypeError): React.useRef is not a function

Created on 7 Feb 2019  路  2Comments  路  Source: pmndrs/react-spring

This is my first time working with this package, so I'm not sure if this is a bug or I'm doing something wrong? Removing the useSpring function clears the error. It's also worth noting that I'm using NextJs.

https://codesandbox.io/s/687004x5n

The error

Unhandled Rejection (TypeError): React.useRef is not a function

index.js

import { useSpring, animated } from "react-spring";

export default () => {
  const props = useSpring({ opacity: 1, from: { opacity: 0 } })
  return <animated.div style={props}>I will fade in</animated.div>
}

package.json

{
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "next": "^7.0.2",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-spring": "^8.0.2"
  }
}

Most helpful comment

you need to use react 16.8.0 (which introduces hooks). i will make this more obvious in the docs, sorry for the confusion. the peer-dependency is set, though, did it warn you in the installation?

All 2 comments

you need to use react 16.8.0 (which introduces hooks). i will make this more obvious in the docs, sorry for the confusion. the peer-dependency is set, though, did it warn you in the installation?

Just ran into this issue, but yes, there is a warning in the installation.
screen shot 2019-02-12 at 6 10 52 pm

Was this page helpful?
0 / 5 - 0 ratings