Skip to content

Instantly share code, notes, and snippets.

@cef62
Created February 5, 2016 09:42
Show Gist options
  • Save cef62/d1995243a174c3fec929 to your computer and use it in GitHub Desktop.
Save cef62/d1995243a174c3fec929 to your computer and use it in GitHub Desktop.
Example of Redux without Redux
// 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