In react-redux the useDispatch hook gives us access to our store's dispatch method. Dispatch is used to send actions into our redux store and is the only way we can affect the store from within a component.
const dispatch = useAppDispatch();
dispatch({ type: "featureName/actionName, payload: {} })
The only works with function components. Class components cannot use hooks and need to use the legacy connect higher order component and a mapDispatchToProps function to gain a way to dispatch actions from components.
Actions with redux are recommended to follow the flux standard action format, which always includes type
field and usually a payload
key containing the primary data associated with the action.