ERROR #11328 A page component must export a React component ... undefined
See original GitHub issueDescription
I’m getting a funky error 11328 with unhelpful debugging information when I run gatsby build
. Running gatsby develop
works fine.
Steps to reproduce
Updated all my dependencies to latest, tried to build the project, it failed.
ERROR #11328
A page component must export a React component for it to be valid. Please make sure this file exports a React component:
undefined
not finished createPagesStatefully - 0.039s
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Here’s a minimal-ish repository I extracted from my project where this fails: https://github.com/Swizec/reactd3lander/tree/error-11328
It correctly shows a single “Hello world” page when you run development mode.
Expected result
The project should build
Actual result
ERROR #11328
A page component must export a React component for it to be valid. Please make sure this file exports a React component:
undefined
not finished createPagesStatefully - 0.039s
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Environment
System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 83.0.4103.61
Firefox: 71.0
Safari: 13.1.1
npmPackages:
gatsby: ^2.23.1 => 2.23.1
gatsby-image: 2.4.6 => 2.4.6
gatsby-plugin-catch-links: ^2.3.4 => 2.3.4
gatsby-plugin-facebook-pixel: ^1.0.3 => 1.0.3
gatsby-plugin-google-analytics: ^2.3.3 => 2.3.3
gatsby-plugin-manifest: ^2.4.10 => 2.4.10
gatsby-plugin-mdx: ^1.2.14 => 1.2.14
gatsby-plugin-react-helmet: ^3.3.3 => 3.3.3
gatsby-plugin-sharp: ^2.6.10 => 2.6.10
gatsby-plugin-simple-analytics: ^1.0.3 => 1.0.3
gatsby-plugin-theme-ui: ^0.3.0 => 0.3.0
gatsby-plugin-twitter: ^2.3.3 => 2.3.3
gatsby-remark-copy-linked-files: ^2.3.4 => 2.3.4
gatsby-remark-embedder: ^2.1.1 => 2.1.1
gatsby-remark-giphy: ^1.0.4 => 1.0.4
gatsby-remark-images: ^3.3.9 => 3.3.9
gatsby-remark-relative-images: ^0.3.0 => 0.3.0
gatsby-remark-social-cards: ^0.4.1 => 0.4.1
gatsby-source-filesystem: ^2.3.10 => 2.3.10
gatsby-transformer-remark: ^2.8.14 => 2.8.14
gatsby-transformer-sharp: ^2.5.4 => 2.5.4
npmGlobalPackages:
gatsby-cli: 2.7.54
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:16 (6 by maintainers)
Top Results From Across the Web
gatsby build error #11328 A page component must export a ...
I had this issue and it was due to use of a file, pages/components.js , that didn't export a default. I modified it...
Read more >How to solve "A page component must export a React ...
From the error message (#11328), it looks like "You have to export the correct React Component for the Page component in Gatsby!
Read more >Attempting to render JSX element but getting undefined
In React it's a convention to export one component from a file, and to export it is as the default export. You're free...
Read more >WARZONE ERROR CODE 11328 MODERN WARFARE FIX ...
Users are facing this issue WARZONE ERROR CODE 11328 MODERN WARFARE. Lets find the cause of this problem and is there any fix...
Read more >How to Read React Errors (fix 'Cannot read property of ...
Got an error like this in your React component? Cannot read property `map` of undefined. In this post we'll talk about how to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey. Thanks for the report. This should be fixed in gatsby@2.23.2
One more thing to add
If you are using
typescript
withgatsby-plugin-page-creator
andstyled-components
is very common create a file namedstyles.tsx
, you must be sure you are ignoring this files ongatsby-plugin-page-creator
ingatsby-config.js