A
A
Alexander2021-03-14 22:10:36
React
Alexander, 2021-03-14 22:10:36

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

1 answer(s)
A
Anvar Shakhmaev, 2021-03-14
@RxR

dispatch(login(() => formik.setStatus(statusObj)));
...
export const login = (successCallback) => (dispatch) => ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question