ReferenceError: React is not defined

Highlighted
Tourist
4 0 1

Hi

 

I am following the tutorial: 

 

https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/build-your-user-interface-with...

I add the _app.js file and run 'npm run dev' but getting 

ReferenceError: React is not defined

I guess the documentation is not up to date or what I am doing wrong?

Thanks for help

Machu

Highlighted
New Member
1 0 0

I was getting the exact same issue. I was getting a few WARNs when I ran `npm install` so, I downgraded the react and react-dom down to what it was asking it to be a minimum version of, in my case it was the following in package.json: 

```

"react": "16.9.0",
"react-dom": "16.9.0"
```
 
Works after selecting these older versions!
0 Likes
Highlighted
Tourist
4 0 1

I see. I fixed the issue. I just import the React library. I thought next.js would handle everything for me.

0 Likes
Highlighted
New Member
2 0 1

I have sample issue, could you please help me where I do need to import React and how? I'm new here and follow the tutorial to learn but seems tutorial is not good enough! 

0 Likes
Highlighted
New Member
2 0 1

Never mind, I found how to do. 

For people who will be stuck like me, just add these line on top of _app.js

import React from 'react';
import ReactDOM from 'react-dom';