Created
November 15, 2021 07:19
-
-
Save matthewoestreich/c5964d885603c0f52d983ac4fc4b4dea to your computer and use it in GitHub Desktop.
React/Babel
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 http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="root"></div> | |
<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="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
<script type="text/babel"> | |
function Echo({ initialVal = "", ...props }) { | |
const [val, setVal] = React.useState(initialVal); | |
return ( | |
<div> | |
<input type="text" value={val} onChange={e => setVal(e.target.value)} /> | |
<h1>{val}</h1> | |
</div> | |
) | |
} | |
function App() { | |
return <Echo initialVal="Hello, World!" /> | |
} | |
ReactDOM.render( | |
<App />, | |
document.querySelector("#root") | |
) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment