Created
January 2, 2024 15:40
-
-
Save ericpkatz/e94274aeed7ff215ba08dc9744d54215 to your computer and use it in GitHub Desktop.
React Starting Point
This file contains 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> | |
<body> | |
<div id="root"></div> | |
</body> | |
<!-- This setup is not suitable for production. --> | |
<!-- Only use it in development! --> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.0/dist/es-module-shims.js"></script> | |
<script type="importmap"> | |
{ | |
"imports": { | |
"react": "https://esm.sh/react?dev", | |
"react-dom/client": "https://esm.sh/react-dom/client?dev" | |
} | |
} | |
</script> | |
<script type="text/babel" data-type="module"> | |
import React from 'react'; | |
import { createRoot } from 'react-dom/client'; | |
function App() { | |
const [numbers, setNumbers] = React.useState([1, 2, 3]); | |
return ( | |
<div> | |
<h1>Numbers App { numbers.length }</h1> | |
<button onClick={function(){ setNumbers([...numbers, Math.random()])}}>+</button> | |
<ul> | |
{ | |
numbers.map(function(num){ | |
return ( | |
<li> | |
{ | |
num | |
} | |
</li> | |
); | |
}) | |
} | |
</ul> | |
</div> | |
); | |
} | |
const root = createRoot(document.getElementById('root')); | |
root.render( | |
<App /> | |
); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment