I'm getting this error in the Formik props. I've been working with formik for a long time, and this is the first time it happens to me
Error: React.Children.only expected to receive a single React element child. Formik
634 views Asked by Miguel Estigarribia At
3
There are 3 answers
0
On
Formik's children should be either a single react node, or a render function.
So you'll get error in case of multiple child nodes e.g.:
<Formik initialValues={...} onSubmit={() => ...}>
<Field name="foo" ... />
<hr>
<MyFields ... />
</Formik>
which you can fix simply by wrapping them in a Fragment:
<Formik initialValues={...} onSubmit={() => ...}>
<>
<Field name="foo" ... />
<hr>
<MyFields ... />
</>
</Formik>
</>
); export default Contacto;