Created
September 6, 2018 19:25
-
-
Save leahpjoyce/03bcba1888c1ed5003d5c1ff8f26c981 to your computer and use it in GitHub Desktop.
Passing Data
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> |
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
function ClickyButtons({numberOfButtons, onSelection}) { | |
const makeButton = v => <button key={v} id={v} onClick={event => onSelection(event.target.id)}>{v}</button>; | |
return <div> | |
{_.range(1, numberOfButtons + 1).map(makeButton)} | |
</div>; | |
} | |
ReactDOM.render(<ClickyButtons numberOfButtons={99} onSelection={console.log}/>, | |
document.getElementById('root') | |
); |
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
<script src="//unpkg.com/react/umd/react.development.js"></script> | |
<script src="//unpkg.com/react-dom/umd/react-dom.development.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment