Before we end this chapter, let's test our knowledge with some questions:
- Is the type property in action objects required, and does this property need to be called type? Can we call it something else?
- How many properties can the action object contain?
- What is an action creator?
- Why did we need Redux Thunk in our Redux store in our React shop app?
- Could we have used something else other than Redux Thunk?
- In our basketReducer we have just implemented, why didn't we just use the push function to add the item to the basket state? That is, what is wrong with the highlighted line?
export const basketReducer: Reducer<IBasketState, BasketActions> = (
state = initialBasketState,
action
) => {
switch (action.type) {
case BasketActionTypes.ADD: {
state.products.push(action.product);
}
}
return state || initialBasketState;
};