Answer the question
In order to leave comments, you need to log in
Why does Formik cause recursion on initialization?
I have a component that has a form
<Formik
onSubmit={...}
enableReinitialize
initialValues={oldValues}
>
<CurrentForm />
</Formik>;
function CurrentForm() {
const { values, setFieldValue, handleSubmit } = useFormikContext();
return (
<div onSubmit={handleSubmit}>
<Input1 />
<Input2 />
<Input3 />
<Button />
</div>
);
}
Answer the question
In order to leave comments, you need to log in
The first thing that catches your eye is that div is used in place of the form tag. Replace as this is mistake
function CurrentForm() {
const { values, setFieldValue, handleSubmit } = useFormikContext();
return (
<form onSubmit={handleSubmit}>
<Input1 />
<Input2 />
<Input3 />
<Button />
</form >
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question