doc: create initialState and reducer method
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export const initialState = {
|
||||
basket: [],
|
||||
};
|
||||
|
||||
const reducer = (state, action) => {
|
||||
switch (action.type) {
|
||||
case "ADD_TO_BASKET":
|
||||
return {
|
||||
...state,
|
||||
basket: [...state.basket, action.item],
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default reducer;
|
||||
|
||||
Reference in New Issue
Block a user