Answer the question
In order to leave comments, you need to log in
How to use Formik setStatus() inside thunk?
export const login = (email: string, password: string, rememberMe: boolean, captcha: string): ThunkType => async (
dispatch
) => {
let loginData = await AuthAPI.login(email, password, rememberMe, captcha)
if (loginData.resultCode === ResultCodesEnum.Success) {
dispatch(getAuthUserData())
} else {
if (loginData.resultCode === ResultCodeCaptchaEnum.CaptchaIsRequired) {
dispatch(getCaptchaUrl())
}
let message = loginData.messages.length > 0 ? loginData.messages[0] : 'Some error'
// setStatus(message)
}
}
Answer the question
In order to leave comments, you need to log in
dispatch(login(() => formik.setStatus(statusObj)));
...
export const login = (successCallback) => (dispatch) => ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question