doc: create initialState and reducer method

This commit is contained in:
Leon Xu
2022-05-05 21:26:27 -07:00
parent 9e5f2605f3
commit 775c4fb5b1
+18
View File
@@ -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;