Last active
December 27, 2019 12:52
-
-
Save ThadeuLuz/9995827d63ebadd9249fa5c0da6f18eb to your computer and use it in GitHub Desktop.
Example HOC for unstated
This file contains hidden or 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 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