I'm trying to create a simple website using React, but for some reason it just displays a blank page.
The error that show up on the console log is Uncaught SyntaxError: Unexpected token '<' main.js:6, which is a really normal line. Can somebody tell me where the error is?
Many thanks.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>U4Ever</title>
</head>
<body>
<div id="root"></div>
<script src="main.js" type="module"></script>
</body>
</html>
Main JS:
import React from "react"
import ReactDOM from "react-dom"
import _navbar from "./navbar.js"
import _body from "./body.js"
ReactDOM.render(<_navbar />, document.getElementById("root"))
ReactDOM.render(<_body />, document.getElementById("root"))
Navbar:
import React from "react"
function navbar() {
return(
<navbar>
<a href="#">Articles</a>
<a href="#">Notes</a>
<a href="#">Course</a>
<a href="#">Brain</a>
<a href="#">Newsletter</a>
<a href="#">Facebook</a>
</navbar>
)
}
export default navbar
Body
import React from "react"
function body() {
return (
<div>
<h1>Hi, I'm Me</h1>
<p>Lorem Ipsum</p>
</div>
)
}
export default body