2

I've attached copies of the code below. Only two files in my project now, app.js and index.html. When I go to google developers' tool and console, the log statement isn't going through. When I type react or react-dom into console I am told Reference Error: React is not defined. This is what a Udemy tutorial has told me to do last updated 5/19 so this should work. I have tried putting import React from "react"; in the top of the files but that doesn't work either. Any suggestions?

//app.js
console.log("App.js is running!)


//index.html
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Indecision App</title>
</head>

<body>
  <script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
  <script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
  <script src="/scripts/app.js"></script>
</body>

</html>
6
  • Does it work if you use any current version of react, i.e. React 16.x? Commented Sep 26, 2020 at 0:31
  • Are you typing them in lower case like 'react' and 'react-dom'? If so, try React and ReactDOM (no dash in between) Commented Sep 26, 2020 at 0:34
  • @Drew Reese. Whoops, I edited it to RN 16.x which is what I meant to originally post! But nope, that does not solve the error! Commented Sep 26, 2020 at 0:41
  • @ultimoTG. I have tried both with uppercase, lowercase, with dash, and without dash, still have the same error! Commented Sep 26, 2020 at 0:42
  • 1
    Seems CDN link may also need to specify a crossorigin attribute on the scripts. Commented Sep 26, 2020 at 0:45

1 Answer 1

1

Looks like you'll need to also specify the crossorigin attribute on the scripts as per the react CDN-links docs.

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.