Skip to content

Instantly share code, notes, and snippets.

@puppybits
Created October 5, 2016 06:43
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 puppybits/38edb92259d75624d605dc4237e759c5 to your computer and use it in GitHub Desktop.
Save puppybits/38edb92259d75624d605dc4237e759c5 to your computer and use it in GitHub Desktop.
Learn JS in 2016
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js"></script>
<div id="app"></div>
<script>
var el = React.createElement;
// create a component
var item = function(props){
return el('li', null, props.children);
}
// create another component
var navbar = function(allNames){
return el('ul', null, allNames.map(function(name){
return el(item, {key:name}, name)
}));
}
// repeat with more components
</script>
<script>
ReactDOM.render(
el('div', null, navbar(['everything', 'is', 'a', 'component'])),
document.querySelector('#app'))
// don't add anything else until you absolutely need it
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment