Skip to content

Instantly share code, notes, and snippets.

@geoffmiller
Forked from StevenLangbroek/01_fn.js
Created November 1, 2016 15:02
Show Gist options
  • Save geoffmiller/84ee4f18a6f19c81ff68ca48c5a75c06 to your computer and use it in GitHub Desktop.
Save geoffmiller/84ee4f18a6f19c81ff68ca48c5a75c06 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