Created
April 17, 2016 09:25
-
-
Save StevenLangbroek/1c176d0504d03a5d5cf93759fa8d20f6 to your computer and use it in GitHub Desktop.
fn
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
export default (fn, ...args) => (e) => { | |
e.preventDefault(); | |
fn(...args); | |
}; |
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
import React, { PropTypes } from 'react'; | |
import fn from 'utils/fn'; | |
const sayHi = (name) => alert(`Hi ${name}`); | |
const HelloWorld = ({ name }) => ( | |
<div> | |
<a | |
href="#" | |
onClick={fn(sayHi, name)} | |
/> | |
Say Hi! | |
</a> | |
</div> | |
); | |
HelloWorld.propTypes = { | |
name: PropTypes.string.isRequired | |
}; | |
export default HelloWorld |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment