Created
October 5, 2016 06:43
-
-
Save puppybits/38edb92259d75624d605dc4237e759c5 to your computer and use it in GitHub Desktop.
Learn JS in 2016
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
<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