Gatsby: React-Spring support

Created on 26 Apr 2018  路  4Comments  路  Source: gatsbyjs/gatsby

````

import { Parallax, ParallaxLayer } from 'react-spring'
const Page = ({ offset, caption, first, second, gradient, onClick }) => (


<Parallax.Layer offset={offset} speed={-0.2} onClick={onClick}>
  <div className={`slopeEnd ${gradient}`} />
</Parallax.Layer>

<Parallax.Layer className="text number" offset={offset} speed={0.3}>
  <span>0{offset + 1}</span>
</Parallax.Layer>

<Parallax.Layer className="text header" offset={offset} speed={0.4}>
  <span>
    <p style={{ fontSize: 20 }}>{caption}</p>
    <div className={`stripe ${gradient}`} />
    <p>{first}</p>
    <p>{second}</p>
  </span>
</Parallax.Layer>


)

const scroll = to => this.refs.parallax.scrollTo(to)
const IndexPage = ({ transition }) => (

className="container"
ref="parallax"
pages={3}
horizontal
scrolling={false}
>
offset={0}
gradient="pink"
caption="who we are"
first="Lorem ipsum"
second="dolor sit"
onClick={() => this.scroll(1)}
/>
offset={1}
gradient="teal"
caption="what we do"
first="consectetur"
second="adipiscing elit"
onClick={() => this.scroll(2)}
/>
offset={2}
gradient="tomato"
caption="what we want"
first="Morbi quis"
second="est dignissim"
onClick={() => this.scroll(0)}
/>


Go to cat


)
````

```
Unhandled promise rejection
TypeError: React.createContext is not a function
Stack trace:
./node_modules/react-spring/dist/react-spring.cjs.js@http://localhost:8001/commons.js:46226:29
__webpack_require__@http://localhost:8001/commons.js:556:12

````

question or discussion

Most helpful comment

createContext is a React 16.3 feature. Can you console.log(React.version) and see what the result is?

I鈥檓 sure you have gatsby-plugin-react-next installed, since React.Fragment doesn鈥檛 throw an error.

If you鈥檙e on < 16.3, you can uninstall and reinstall gatsby-plugin-react-next so that it鈥檒l reinstall the latest React version.

All 4 comments

createContext is a React 16.3 feature. Can you console.log(React.version) and see what the result is?

I鈥檓 sure you have gatsby-plugin-react-next installed, since React.Fragment doesn鈥檛 throw an error.

If you鈥檙e on < 16.3, you can uninstall and reinstall gatsby-plugin-react-next so that it鈥檒l reinstall the latest React version.

console.log(React.version) = React not defined.

"gatsby-plugin-react-next": "^1.0.11",

TypeError: react__WEBPACK_IMPORTED_MODULE_0___default.a.createContext is not a function

"gatsby": "2.0.0-alpha.23",

If you鈥檙e using Gatsby v2, you need to install React and react-dom manually. I would avoid using v2 until it goes on beta.

Was this page helpful?
0 / 5 - 0 ratings