1// Dispatches an action; this changes the state
2store.dispatch({ type: 'INCREMENT' })
3store.dispatch({ type: 'DECREMENT' })
4
1// Optional - you can pass `initialState` as a second arg
2let store = createStore(counter, { value: 0 })
3
1// Reducer
2function counter (state = { value: 0 }, action) {
3 switch (action.type) {
4 case 'INCREMENT':
5 return { value: state.value + 1 }
6 case 'DECREMENT':
7 return { value: state.value - 1 }
8 default:
9 return state
10 }
11}
12