Skip to content

Instantly share code, notes, and snippets.

@juhahinkula
Created April 19, 2020 15:48
Show Gist options
  • Save juhahinkula/c350bac109f9d66facf25eeeb4b72125 to your computer and use it in GitHub Desktop.
Save juhahinkula/c350bac109f9d66facf25eeeb4b72125 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>React getting started</title>
</head>
<body>
<!-- Root container for react components -->
<div id='root'></div>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
function HelloReact() {
const [word, setWord] = React.useState('');
const [revWord, setRevWord] = React.useState('');
const inputChanged = () => {
setWord(event.target.name)
}
reverseWord = () => {
const rev = word.split("").reverse().join("");
setRevWord(rev);
}
return (
{revWord}<br />
<input onChange={inputChanged} value={word} /><br />
<Button onClick={reverseWord}>Reverse</Button>
);
}
ReactDOM.render(<HelloReact />, document.getElementById('root'));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment