Skip to content

Instantly share code, notes, and snippets.

@syntacticsugar
Created June 13, 2016 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syntacticsugar/b05818d76d56d54f899060e5cd6a4e44 to your computer and use it in GitHub Desktop.
Save syntacticsugar/b05818d76d56d54f899060e5cd6a4e44 to your computer and use it in GitHub Desktop.
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