Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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