at first mount field has 0 errors with defined "initialValue" and "validateOnMount" flag
at the first mount, the validation field must have an error.
https://codesandbox.io/s/formik-codesandbox-template-723xp
at [email protected] all works fine.
| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 2.1.5
| React | 16.11.0
Looks like this works in 2.1.4 as well. I believe my PR #2625 will fix this.
same issue on 2.1.5
Any update on this? I'd like to be able to update Formik to keep my dependencies up to date but this issue is stopping me.
In the last version the property isInitialValid is marked as deprecated, but this was only way to disable submit button on initial empty form. Current initialErrors with validation schema makes the form valid on start even if it invalid (empty).
for now I'm using like this:
import React, { useRef, useEffect } from 'react'
import {
Formik as BaseFormik,
Form as BaseForm,
FormikProps,
FormikConfig,
} from 'formik'
function Formik<Values>(props: FormikConfig<Values>) {
const { children, ...rest } = props
const formRef = useRef<FormikProps<Values> | null>(null)
useEffect(() => {
if (formRef.current) {
formRef.current.validateForm()
}
}, [])
return (
<BaseFormik innerRef={formRef} {...rest}>
<BaseForm>{children}</BaseForm>
</BaseFormik>
)
}
// Workaround for: https://github.com/formium/formik/issues/2652
export default Formik
So instead of import from formik I'm using this component
Appears to be fixed in 2.1.6?
@cduff
Yes, I can confirm that it is fixed in 2.1.6.
Yep. CONFIRMED TOO -- The bug is present in 2.1.5, but fixed in 2.1.6 -- I just upgraded and tried it.
Yeap, confirm. It's working in 2.1.6
Most helpful comment
@cduff
Yes, I can confirm that it is fixed in 2.1.6.