Skip to content

Instantly share code, notes, and snippets.

@tylermcginnis
Created April 9, 2018 06:40
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save tylermcginnis/fac1d0fec1f9041cc55663dda6c43419 to your computer and use it in GitHub Desktop.
Save tylermcginnis/fac1d0fec1f9041cc55663dda6c43419 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>React</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src='https://unpkg.com/babel-standalone@6/babel.min.js'></script>
</head>
<body>
<div id='app'></div>
<script type='text/babel'>
function NameComponent ({ name }) {
return <h1>{name}</h1>
}
function HandleComponent ({ handle }) {
return <h3>{handle}</h3>
}
function App () {
return (
<div id='container'>
<HandleComponent handle='@tylermcginnis' />
<NameComponent name='Tyler' />
</div>
)
}
ReactDOM.render(
<App />,
document.getElementById('app')
)
</script>
</body>
</html>
@yingluwang
Copy link

Hi Tyler,

I am learning React by following your recording. I am using node v8.9.4, do I still need to precompile Babel? It gave me error when I put <script src='https://unpkg.com/babel-standalone@6/babel.min.js'></script> in .

If I took it off, nothing showed up in my browser.

I included <script type='text/babel'> in both scenarios.

@jeffhou
Copy link

jeffhou commented Aug 26, 2018

@yingluwang You don't need any compilation. Just download this file and open on your browser. It should immediately work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment