-
-
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
types: Align FormikHelpers and FieldHelper types to useFormik ones #3843
Conversation
🦋 Changeset detectedLatest commit: 4adda22 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 ↗︎ 1 Ignored Deployment
|
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. Latest deployment of this branch, based on commit 4adda22:
|
/** Manually set values object */ | ||
setValues: ( | ||
values: React.SetStateAction<Values>, | ||
shouldValidate?: boolean | ||
) => void; | ||
) => Promise<void | FormikErrors<Values>>; |
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.
@@ -86,12 +86,12 @@ export interface FormikHelpers<Values> { | |||
setTouched: ( | |||
touched: FormikTouched<Values>, | |||
shouldValidate?: boolean | |||
) => void; | |||
) => Promise<void | FormikErrors<Values>>; |
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.
@@ -105,11 +105,11 @@ export interface FormikHelpers<Values> { | |||
field: string, | |||
isTouched?: boolean, | |||
shouldValidate?: boolean | |||
) => void; | |||
) => Promise<void | FormikErrors<Values>>; |
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.
/** Validate form values */ | ||
validateForm: (values?: any) => Promise<FormikErrors<Values>>; | ||
/** Validate field value */ | ||
validateField: (field: string) => void; | ||
validateField: (field: string) => Promise<void> | Promise<string | undefined>; |
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.
@probablyup is there something more I need to do to make this PR reviewable? |
Just haven't had time to look at it yet |
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.
Looks fantastic, thank you!
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## formik@2.4.3 ### Patch Changes - [`9e0a661`](9e0a661) [#3843](#3843) Thanks [@bonimba](https://github.com/bonimba)! - Fix FormikHelper and FieldHelperProps types ## formik-native@2.1.26 ### Patch Changes - Updated dependencies \[[`9e0a661`](9e0a661)]: - formik@2.4.3
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## formik@2.4.3 ### Patch Changes - [`9e0a661`](jaredpalmer/formik@9e0a661) [#3843](jaredpalmer/formik#3843) Thanks [@bonimba](https://github.com/bonimba)! - Fix FormikHelper and FieldHelperProps types ## formik-native@2.1.26 ### Patch Changes - Updated dependencies \[[`9e0a661`](jaredpalmer/formik@9e0a661)]: - formik@2.4.3
This is yet another PR around TypeScript.
The inferred types for the helpers in
useFormik
are the correct ones and should be used everywhere.See
Having the correct types, and the awaiting these helpers helps with otherwise possible race conditions when used in an imperative way, like so