rsnext/examples/with-redux-reselect-recompose/reducers/count.js
Luis Fernando Alvarez D 9455a8b242 Update example: with redux reselect recompose (#7624)
* Removed eslint packages and module-resolver from the example

* Removed unused package
2019-06-22 10:24:06 -07:00

30 lines
507 B
JavaScript

import { ADD, TICK } from '../constants/actionTypes'
export const initialState = {
lastUpdate: 0,
light: false,
count: 0
}
export default (state = initialState, action) => {
const { type, ts, light } = action
switch (type) {
case TICK: {
return Object.assign({}, state, {
lastUpdate: ts,
light: !!light
})
}
case ADD: {
return Object.assign({}, state, {
count: state.count + 1
})
}
default: {
return state
}
}
}