PlusMinusSet
This commit is contained in:
17
lab07/src/reducer.js
Normal file
17
lab07/src/reducer.js
Normal file
@ -0,0 +1,17 @@
|
||||
const initialState = {
|
||||
count: 100,
|
||||
fifeTHousend: 5000,
|
||||
};
|
||||
|
||||
export default function reducer(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case "count/increaseBy":
|
||||
return { ...state, count: state.count + action.amount };
|
||||
case "count/decreaseBy":
|
||||
return { ...state, count: state.count - action.amount };
|
||||
case "count/setToFiveThousand":
|
||||
return { ...state, count: state.fifeTHousend };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user