Created
June 13, 2016 16:49
-
-
Save syntacticsugar/b05818d76d56d54f899060e5cd6a4e44 to your computer and use it in GitHub Desktop.
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
const counter = (state=0, action) => { | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1; | |
case 'DECREMENT': | |
return state - 1; | |
default: | |
return state; | |
} | |
} | |
const { createStore } = Redux; | |
// same as doing: | |
// var createStore = Redux.createStore; | |
// import { createStore } from 'redux'; | |
const store = createStore(counter); | |
console.log(store.getState()) // returns state | |
store.dispatch({ type: 'INCREMENT'}); | |
console.log(store.getState()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment