Created
February 5, 2016 09:42
-
-
Save cef62/d1995243a174c3fec929 to your computer and use it in GitHub Desktop.
Example of Redux without Redux
This file contains 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
// see: https://github.com/rackt/redux/issues/1367#issuecomment-180073370 | |
import reducer, { increment, decrement } from 'redux-counter' | |
class App extends Component { | |
constructor() { | |
super() | |
this.state = reducer(undefined, {}) | |
} | |
dispatch(action) { | |
this.setState(state => reducer(state, action)) | |
} | |
render() { | |
return ( | |
<Counter | |
{...this.state} | |
onIncrement={() => this.dispatch(increment())} | |
onDecrement={() => this.dispatch(decrement())} | |
/> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment