I just started looking into ReactJS (not really experienced with any of the javascript libraries or frameworks, except for jQuery).
I followed the following pages from the ReactJS website (https://reactjs.org/docs/add-react-to-a-website.html and https://reactjs.org/docs/hello-world.html), but I keep getting the same error:
Uncaught SyntaxError: Unexpected token <
I don't really know what causes this, when I use this code in CodePen, it works just fine. Do I need to add a couple of other JS files in my index?
Current files:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div id="root"></div>
<!-- Scripts -->
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="js/scripts.js" type="text/javascript"></script>
</body>
</html>
JS
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
Thank you all in advance!
PS: when I add import React and import ReactDOM, I get an Unexpected identifier error.
React.createElementcalls, so you must compile it or use Babel in the browser for testing purposes. - Tholle