Skip to content

Instantly share code, notes, and snippets.

@MicroBenz
Created December 3, 2017 15:58
Show Gist options
  • Save MicroBenz/e75426d12e658519b018c6be1ae1ec77 to your computer and use it in GitHub Desktop.
Save MicroBenz/e75426d12e658519b018c6be1ae1ec77 to your computer and use it in GitHub Desktop.
Recompose
import React from 'react';
import { withState } from 'recompose';
const enhance = withState('counter', 'setCounter', 0);
const Counter = enhance(props => (
<div>
Count: {props.counter}
<button onClick={() => props.setCounter(props.counter + 1)}>Increase</button>
<button onClick={() => props.setCounter(props.counter - 1)}>Decrease</button>
</div>
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment