-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(2172)!: validateOnMount initialize isValid to false until validation performed #3984
base: main
Are you sure you want to change the base?
fix(2172)!: validateOnMount initialize isValid to false until validation performed #3984
Conversation
🦋 Changeset detectedLatest commit: 33818d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
affb616
to
33818d3
Compare
@@ -152,6 +152,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({ | |||
const initialTouched = React.useRef(props.initialTouched || emptyTouched); | |||
const initialStatus = React.useRef(props.initialStatus); | |||
const isMounted = React.useRef<boolean>(false); | |||
const validated = React.useRef<boolean>(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your move to add a ref here is right, but we should be running validation synchronously on mount if validateOnMount
is set such that validation has occurred within the first render pass and there is no potential for the boolean to flip either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should i run validation synchronously since it may be async ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quantizor any hint ? this cause annoying UI issue for me
Related to 2172
Maybe it could be extended to use cases without validateOnMount but with validate function or validationSchema ?