birkir / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
137 stars 75 forks source link

WebpackError: TypeError: Cannot read property 'node' of undefined - only on build #134

Open ThermalIDTechnologies opened 4 years ago

ThermalIDTechnologies commented 4 years ago

I am getting an error on build when trying to set Prismic nodes to state using the useState hook before the return. This works just fine on develop. If anyone has any ideas or solutions for this problem I would be so grateful to hear them!

Example: Firefox_Screenshot_2020-01-23T01-11-35 426Z

Error: image

Here is a codesandbox recreating my problem. The code mentioned in this post is in src/templates/ProductDetailTemplate.js https://codesandbox.io/s/gatsby-prismic-test-01bdv?fontsize=14&hidenavigation=1&theme=dark