I am a bit confused when it comes to dispatching actions. In the actions sometimes I see this:
export const getConfig = () => dispatch => {
const res = await axios.get('/api/users');
dispatch({
type : TYPES.GET_CONFIG,
payload : res.data
});
}
and sometimes I see:
export const getConfig = () => {
const res = await axios.get('/api/users');
return{
type : TYPES.GET_CONFIG,
payload : res.data
};
}
Are they both same? or they have their own use cases? When to use what?
Thanks.