-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't export anything but string or react component w/in pages directory #2787
Comments
Ah yeah — any JS file under pages, Gatsby treats as a page component so it must have a default export that's a component. Try moving data.js to |
hmm that's what I figured immediately after you tweeted back! Thank you! Can I open a PR to update this page to add a third list item: https://www.gatsbyjs.org/docs/debugging-html-builds/ something like:
No worries if you don't it's necessary but would've saved me a half day of debugging. |
That'd be super helpful! Sorry about the debugging pain :-( |
Let me know if this is good or I should make additional notes/changes. Feel free to close out this issue and/or merge the PR if everything looks good! |
🥇 |
I like keeping files local to the components that use them. I have test files and CSS-In-JS files with some of my pages. Adding the following ignore to the gatsby-plugin-page-creator does nothing.
|
Here is my setup
data.js:
index.js:
import { someArr, someObj } from './data'
throws this error:

which links to this:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: [missing argument].[missing argument]
Observations:
when I delete the
import {} ...
line, the error is still thrown. It appears the mere presence of thedata.js
file is breaking thingswhen I change the exports to strings, everything works fine.
when I move the
someArr
andsomeObj
into theindex.js
file, everything works fine.Thoughts?
The text was updated successfully, but these errors were encountered: