-
-
Save geoffmiller/84ee4f18a6f19c81ff68ca48c5a75c06 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