Skip to content

Instantly share code, notes, and snippets.

@oze4
Created November 15, 2021 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oze4/c5964d885603c0f52d983ac4fc4b4dea to your computer and use it in GitHub Desktop.
Save oze4/c5964d885603c0f52d983ac4fc4b4dea to your computer and use it in GitHub Desktop.
React/Babel
<!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