I am new to React-Redux!
But I have a problem.
How does the inner function (async dispatch) receive the dispatch() parameter?
GetCurrentUserInfo Action Creator function:
export const getCurrentUserInfo = () => async dispatch => {
const response = await axios.get('/api/users/me')
dispatch({
type: userActions.SET_CURRENT_USER_INFO,
users: response.data.data
})
return response.data.data
}
How getCurrentUserInfo is called:
export const AuthGuard = connect(
state => ({
currentUserSlug: state.session.currentUser
}),
dispatch => ({
authOrRedirect: () => {
return dispatch(getCurrentUserInfo()).catch(() => {
history.replace('/login')
})
}
})
)(AuthGuardComponent)
getCurrentUserInfo() does not receive any parameters, but is it because it is enclosed in dispatch(getCurrentUserInfo())?