I followed this answer here:
But after compiling my Browser (Firefox 67) says:
SyntaxError: import declarations may only appear at top level of a module
My app.jsx looks like:
import React from 'react';
import ReactDOM from 'react-dom';
class Alpha extends React.Component {render() { return <h1>Hello</h1>; }}
ReactDOM.render(<Alpha />, document.getElementById('root'));
.babelrc:
{
"presets": ["@babel/preset-react"]
}
index.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="root"></div>
<script src="js/dashboard.js"></script>
</body>
</html>
compiled using babel-cli
Why is that? They said that newer browsers support es6 imports.
Tried:
... type="module"></script>
Result:
TypeError: Error resolving module specifier: react