Answer the question
In order to leave comments, you need to log in
What to replace stopSubmit from Redux Form in Formik?
Please tell me what can be replaced in Formik?
Are there any analogues?
I need to rewrite this code in Formik, thanks in advancestopSubmit(form:String, errors:Object)
import {stopSubmit } from 'redux-form'
dispatch(stopSubmit('login', { _error: message }))
Answer the question
In order to leave comments, you need to log in
You probably don't need any more. But maybe someone can help.
There is setStatus, you can read about it, I'll just explain a little. It works a little differently, because formik doesn't create form in redux. In the onSubmit method in formik, add setStatus to the desired function. Like this:
onSubmit: (values, submitProps) => {
let formData = {
email: values.email,
password: values.password,
rememberMe: values.checkbox,
}
props.onSubmit(formData, submitProps.setStatus)
submitProps.resetForm()
}
export const login = (loginData, setStatus) => {
return (dispatch) => {
authAPI.login(loginData)
.then(data => {
if(data.data.resultCode === 0) {
dispatch(authMe(true))
} else {
setStatus({error: data.data.messages})
}
})
}
}
formik.status.error
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question