Skip to content
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

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/formik/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ export interface FormikHelpers<Values> {
setTouched: (
touched: FormikTouched<Values>,
shouldValidate?: boolean
) => void;
) => Promise<void | FormikErrors<Values>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

/** Manually set values object */
setValues: (
values: React.SetStateAction<Values>,
shouldValidate?: boolean
) => void;
) => Promise<void | FormikErrors<Values>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

/** Set value of form field directly */
setFieldValue: (
field: string,
Expand All @@ -105,11 +105,11 @@ export interface FormikHelpers<Values> {
field: string,
isTouched?: boolean,
shouldValidate?: boolean
) => void;
) => Promise<void | FormikErrors<Values>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

/** Validate form values */
validateForm: (values?: any) => Promise<FormikErrors<Values>>;
/** Validate field value */
validateField: (field: string) => void;
validateField: (field: string) => Promise<void> | Promise<string | undefined>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

/** Reset form */
resetForm: (nextState?: Partial<FormikState<Values>>) => void;
/** Submit the form imperatively */
Expand Down Expand Up @@ -302,9 +302,9 @@ export interface FieldMetaProps<Value> {
/** Imperative handles to change a field's value, error and touched */
export interface FieldHelperProps<Value> {
/** Set the field's value */
setValue: (value: Value, shouldValidate?: boolean) => void;
setValue: (value: Value, shouldValidate?: boolean) => Promise<void | FormikErrors<Value>>;
/** Set the field's touched value */
setTouched: (value: boolean, shouldValidate?: boolean) => void;
setTouched: (value: boolean, shouldValidate?: boolean) => Promise<void | FormikErrors<Value>>;
/** Set the field's error value */
setError: (value: string | undefined) => void;
}
Expand Down