Answer the question
In order to leave comments, you need to log in
How to properly connect React to the site?
There is HTML:
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.js"></script>
<script src="https://unpkg.com/[email protected]/babel.js"></script>
<script src="/r/b2b-spa/js/main.js"></script>
<title>Тайтл</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, world!</h1>, document.getElementById('root')
);
Uncaught SyntaxError: Unexpected token import
Answer the question
In order to leave comments, you need to log in
In the documentation , one of the items you need is: A compiler such as Babel. It lets you write modern JavaScript code that still works in older browsers.
The browser "does not know how to import", so to speak. You need to run your ES2015 scripts through tools like babel .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question