Last active
May 22, 2019 07:51
-
-
Save mikaello/9308e83986a43b3a8bbc11c559b043c0 to your computer and use it in GitHub Desktop.
Write JSX in HTML file
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> | |
<head> | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> | |
<!-- | |
Credit: https://twitter.com/sophiebits/status/1129824393155080192 | |
Also worth checking out: https://www.pikapkg.com/ | |
--> | |
</head> | |
<body> | |
<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://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<script type="text/babel"> | |
const PartyComponent = props => { | |
const [title, setTitle] = React.useState(props.title); | |
return <div onClick={() => setTitle(title.toUpperCase())}>{title}</div>; | |
}; | |
ReactDOM.render( | |
<PartyComponent title="Join the party!" />, | |
document.getElementById('root'), | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment