redox
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 = {
|
||||
input: '',
|
||||
list: []
|
||||
};
|
||||
|
||||
export default function appReducer(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case 'input/update':
|
||||
return { ...state, input: action.payload };
|
||||
case 'input/clear':
|
||||
return { ...state, input: '' };
|
||||
case 'list/add':
|
||||
return { ...state, list: [...state.list, action.payload] };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user