Created
March 28, 2025 04:20
-
-
Save adamar/9e62798b7c54a75ee8001c4f73c68fba to your computer and use it in GitHub Desktop.
Basic React Hello world with ESM imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Hello World React</title> | |
<script type="module"> | |
import React from "https://esm.sh/[email protected]"; | |
import ReactDOM from "https://esm.sh/[email protected]/client"; | |
function App() { | |
return React.createElement("div", null, "hello world"); | |
} | |
const rootElement = document.getElementById("root"); | |
if (rootElement) { | |
ReactDOM.createRoot(rootElement).render(React.createElement(React.StrictMode, null, React.createElement(App))); | |
} else { | |
console.error("Root element not found."); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="root"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment