Answers
- An action can contain as many properties as we like! It needs to include at least one for the
typeproperty. It can then include as many other properties as we need for the reducer to change the state, but this is generally lumped into one additional property usually calledpayload. So, generally, an action will have one or two properties. - We used the
readonlykeyword in the properties in the interface for the state to make it read-only. - The
Providercomponent needs to be placed above the components that need access to the store. So, it doesn't need to be right at the top of the tree. - The
useSelectorhook allows a component to select state from the store. - The
useDispatchhook returns a function that can be used to dispatch an action – it can't be used to dispatch an action directly. Here's the correct way to dispatch an action:const dispatch = useDispatch(); ... dispatch(gettingQuestionAction);
- Yes, a component can have a local...