15 lines
361 B
JavaScript
15 lines
361 B
JavaScript
// @flow
|
|
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../actions/counter';
|
|
import type { Action } from './types';
|
|
|
|
export default function counter(state: number = 0, action: Action) {
|
|
switch (action.type) {
|
|
case INCREMENT_COUNTER:
|
|
return state + 1;
|
|
case DECREMENT_COUNTER:
|
|
return state - 1;
|
|
default:
|
|
return state;
|
|
}
|
|
}
|