Last active
June 25, 2018 08:46
-
-
Save kdastan/ea8189ea541cbe741deedef7b71f9aa0 to your computer and use it in GitHub Desktop.
n17r - Map example
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
<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"> | |
const rootElement = document.getElementById('root'); | |
const arr = ['todo1', 'todo2'] | |
const renderItems = () => { | |
return arr.map((item, index) => { | |
return <div key={index} onClick={() => console.log('clicked', item)} className="container">{item}</div>; | |
}); | |
} | |
ReactDOM.render(renderItems(), rootElement) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment