Create React App: Cannot read property 'startsWith' of undefined
See original GitHub issueHi,
I’m using graphql.macro@1.3.5
with create-react-app@16.8
, and when I try to import loader
from graphql.macro
, it throws me this:
TypeError: graphql.macro: Cannot read property 'startsWith' of undefined Learn more: https://www.npmjs.com/package/graphql.macro
at Array.forEach (<anonymous>)
at Array.forEach (<anonymous>)
I’m not really sure how to setup babel macros, so I may have forgotten a dependency (by the way, is graphql
really needed?).
Here’s my config:
package.json
{
...
"dependencies": {
...
"graphql": "^14.2.1",
"graphql-request": "^1.8.2",
"graphql.macro": "^1.3.5",
"react": "^16.8.5",
"react-scripts": "2.1.8",
"typescript": "3.3.4000"
...
},
...
}
.babelrc
{
"plugins": ["graphql.macro"]
}
src/components/App.tsx
...
import {loader} from 'graphql.macro';
console.log(loader); // the error is thrown at this point
...
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
TypeError: Cannot read property startsWith of undefined
console.log your this.props.description variable. The only way this error will appear is if it has no value. The reason everything works fine in ......
Read more >Cannot read property 'startsWith' of undefined #354 - GitHub
I installed the library and linked it with react-native link react-native-fs. I try to run the minimal example: RNFS.readDir(RNFS.
Read more >TypeError: Cannot read property 'startsWith' of undefined
Hi, im trying to connect to MongoAtlas run an app that uses mongodb (^4.3.1 ) in nodejs (version 10.19.0), Windows 7 & then...
Read more >TypeError: Cannot read property 'startsWith' of undefined
it means you are calling startsWith(...) on a variable that is undefined somewhere in your function. ... PS, I assume that's not the...
Read more >Vue3 Cannot read property 'startsWith' of undefined - Laracasts
Hi, I'm trying to setup laravel 8, vue 3, inertia, bootstrap 5. I was getting all sort of errors I figured somehow mainly...
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 Free
Top 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
I’ve bumped into the same error. However, it seems that there is some magic going on during compilation that throws this error. Do not try to dump
loader
to the console. Do you get the same error when you are simply using the loader, i.e.loader("./path/to/some.graphql")
?In my case, I’m getting no error when using
loader("./path/to/some.graphql")
but the error only appears as soon as I’m creating a new variableconst myGraphQlFile = "./path/to/some/graphql"; loader(myGraphQlFile);
.Same here, happening when I try to use path to file from a variable. I’d wanted to load a bunch of graphql-files from an array, but it doesn’t allow that 😦