function increment() { return { type: "INCREMENT" } }
function decrement() { return { type: "DECREMENT" } }
function reducer(state = {count: 0}, action) { // return new state based on the incoming action.type switch(action.type) { case "INCREMENT": return { count: state.count + 1 } case "DECREMENT": return { count: state.count - 1 } default: return state } }
const store = redux.createStore(reducer)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function reducer(state = {count:0}, action) {
// return new state based on the incoming action.type