rsnext/examples/with-apollo-and-redux/store.js
Joe Haddad 18a9c7e371
Improve linting rules to catch more errors (#9374)
* Update `packages/`

* Update examples

* Update tests

* Update bench

* Update top level files

* Fix build

* trigger
2019-11-10 19:24:53 -08:00

39 lines
752 B
JavaScript

import { createStore } from 'redux'
const initialState = {
lastUpdate: 0,
light: false,
count: 0,
}
const reducer = (state = initialState, action) => {
switch (action.type) {
case 'TICK':
return {
...state,
lastUpdate: action.lastUpdate,
light: !!action.light,
}
case 'INCREMENT':
return {
...state,
count: state.count + 1,
}
case 'DECREMENT':
return {
...state,
count: state.count - 1,
}
case 'RESET':
return {
...state,
count: initialState.count,
}
default:
return state
}
}
export const initializeStore = (preloadedState = initialState) => {
return createStore(reducer, preloadedState)
}