8000 Add FieldProps change to v2 migration guide by mhelmer · Pull Request #2356 · jaredpalmer/formik · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add FieldProps change to v2 migration guide #2356

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

Merged
merged 3 commits into from
Apr 17, 2020

Conversation

mhelmer
Copy link
Contributor
@mhelmer mhelmer commented Mar 10, 2020

FieldProps had an undocumented breaking change introduced in v2. For users that relied on the previously unary type generic, the FormValues parameter ended up as the type on field.value.

This PR adds documentation for this change in the v1 to v2 migration guide. This fixes #2350

FieldProps in v1.6.8:

export interface FieldProps<V = any> {
  field: {
    /** Classic React change handler, keyed by input name */
    onChange: FormikHandlers['handleChange'];
    /** Mark input as touched */
    onBlur: FormikHandlers['handleBlur'];
    /** Value of the input */
    value: any;
    /* name of the input */
    name: string;
  };
  form: FormikProps<V>; // if ppl want to restrict this for a given form, let them.
}

FieldProps in v2.1.4:

export interface FieldProps<V = any, FormValues = any> {
  field: FieldInputProps<V>;
  form: FormikProps<FormValues>; // if ppl want to restrict this for a given form, let them.
  meta: FieldMetaProps<V>;
}

View rendered docs/migrating-v2.md

@vercel
Copy link
vercel bot commented Mar 10, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/jared/formik-docs/jwgjt332l
✅ Preview: https://formik-docs-git-fork-mhelmer-fieldprops-type-migration.jared.now.sh

@codesandbox-ci
Copy link
codesandbox-ci bot commented Mar 10, 2020

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 d359954:

Sandbox Source
Formik TypeScript Playground Configuration

FieldProps had an undocumented breaking change. This change has now been
added to the v1 to v2 migration guide.
Copy link
Collaborator
@johnrom johnrom left a comment

Choose a reason for hiding this comment

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

Small nitpick, otherwise looks good to me.

@@ -56,6 +58,22 @@ import { FormikActions } from 'formik';
import { FormikHelpers as FormikActions } from 'formik';
```

#### `FieldProps`

**`FieldProps` now accepts two generic type parameters.** Both are optional but `FormValues` needs to be passed as the second parameter.
Copy link
Collaborator
@johnrom johnrom Apr 16, 2020

Choose a reason for hiding this comment

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

"Both parameters are optional, but FormValues has been moved from the first to the second parameter."

The wording currently sounds like "it's optional but needs to be passed."

Choose a reason for hiding this comment

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

Would be great to elaborate what FieldValue means

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johrom: absolutely, I'll update.

@jorilallo: I agree it would be good, but I think it would be better to link into the TypeScript docs. However, it doesn't contain a description of those types.

Copy link
@jorilallo jorilallo Apr 17, 2020

Choose a reason for hiding this comment

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

@mhienle to be clear, I was going through the docs and I had no idea what FieldValue meant, yet alone that it's from TS definitions itself, so an example would not hurt. Same for the actual docs, there's not a single example

Edit: Even in Formik's definitions it's just V = any which doesn't explain anything

@jaredpalmer
Copy link
Owner

LGTM

@jaredpalmer
Copy link
Owner

Thanks @jorilallo

@jaredpalmer jaredpalmer merged commit 4b6731f into jaredpalmer:master Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undocumented breaking change in FieldProps generics
4 participants
0