A Pen by Milad Vafaeifard on CodePen.
Created
July 3, 2018 18:25
-
-
Save miladvafaeifard/b440bed4b23adae2908af3a8494926b2 to your computer and use it in GitHub Desktop.
Passing Data (ReactJs)
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
const makeButton = onSelection => b => <button key={b} id={b} onClick={e => onSelection(e.target.id)} > {b} </button>; | |
const CreateButtons = ({numOfBtn, onSelection}) => <div> { R.range(1, numOfBtn + 1).map(makeButton(onSelection)) } </div> | |
const render = <CreateButtons numOfBtn={19} onSelection={console.log} /> | |
const root = document.getElementById('root'); | |
ReactDOM.render(render, 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="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.0/umd/react.development.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.0/umd/react-dom.development.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment