Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Created April 17, 2016 09:25
Show Gist options
  • Save StevenLangbroek/1c176d0504d03a5d5cf93759fa8d20f6 to your computer and use it in GitHub Desktop.
Save StevenLangbroek/1c176d0504d03a5d5cf93759fa8d20f6 to your computer and use it in GitHub Desktop.
fn
export default (fn, ...args) => (e) => {
e.preventDefault();
fn(...args);
};
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