first commit
This commit is contained in:
22
src/reducers/counter.js
Normal file
22
src/reducers/counter.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { ADD, MINUS } from '../constants/counter'
|
||||
|
||||
const INITIAL_STATE = {
|
||||
num: 0
|
||||
}
|
||||
|
||||
export default function counter (state = INITIAL_STATE, action) {
|
||||
switch (action.type) {
|
||||
case ADD:
|
||||
return {
|
||||
...state,
|
||||
num: state.num + 1
|
||||
}
|
||||
case MINUS:
|
||||
return {
|
||||
...state,
|
||||
num: state.num - 1
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
6
src/reducers/index.js
Normal file
6
src/reducers/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { combineReducers } from 'redux'
|
||||
import counter from './counter'
|
||||
|
||||
export default combineReducers({
|
||||
counter
|
||||
})
|
Reference in New Issue
Block a user