Skip to content

Commit 60b4259

Browse files
committed
Counter reducer
1 parent 9b9c9cd commit 60b4259

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from './actionTypes'
2+
import { CounterActionTypes } from './types'
3+
4+
const initialState = {
5+
value: 0,
6+
}
7+
8+
export default (state = initialState, action: CounterActionTypes) => {
9+
switch (action.type) {
10+
case INCREMENT_COUNTER:
11+
return { ...state, value: state.value + 1 }
12+
case DECREMENT_COUNTER:
13+
return { ...state, value: state.value - 1 }
14+
default:
15+
return state
16+
}
17+
}

0 commit comments

Comments
 (0)