doc: create initialState and reducer method
This commit is contained in:
1 parent
9e5f2605f3
commit
775c4fb5b1
1 file changed
+18
@@ -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