Why doesn't my Hello World work in react?
Can you please tell me where is the bug in this code?
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
<script src="main.js" type="text/babel"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
main.js:
ReactDOM.render(<h1>Hello World</h1>, document.getElementById("#app"));
You do NOT need the hash symbol (#) when using document.getElementById. That is only required when using document.querySelector
ReactDOM.render(<h1>Hello World</h1>, document.getElementById("app"));
<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>
<div id="app"></div>