Skip to content

Instantly share code, notes, and snippets.

@ThadeuLuz
Last active December 27, 2019 12:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThadeuLuz/9995827d63ebadd9249fa5c0da6f18eb to your computer and use it in GitHub Desktop.
Save ThadeuLuz/9995827d63ebadd9249fa5c0da6f18eb to your computer and use it in GitHub Desktop.
Example HOC for unstated
import React from 'react';
import { inject } from 'unstated';
import CounterContainer from './CounterContainer.js';
const Counter = ({ counter }) => (
<div>
<button onClick={() => counter.decrement()}>-</button>
<span>{counter.state.count}</span>
<button onClick={() => counter.increment()}>+</button>
</div>
);
export default inject({ counter: CounterContainer })(Counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment