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

Add initialXXXX and fix isValid #1410

Merged
merged 3 commits into from
Apr 26, 2019
Merged

Add initialXXXX and fix isValid #1410

merged 3 commits into from
Apr 26, 2019

Conversation

jaredpalmer
Copy link
Owner

@jaredpalmer jaredpalmer commented Apr 2, 2019

  • Deprecate isInitialValid with a warning. If it is specified, old 1.x isValid behavior is utilized.
  • isValid is now true by default.
  • Add initialErrors and initialTouched props to <Formik>
  • Add mapPropsToErrors and mapPropsToTouched to withFormik()
  • Breaking: resetForm(nextValues: Values) to resetForm(nextInitialState: FormikState<Values>

I'm not convinced we actually need to change resetForm (and thus keep all of these as refs that can be mutated on reset)

FWIW I can't think of when you would want initialTouched. Open to ideas and would be happy to remove.

Closes #1133 #1116 #1148 #288 #954 #698

@jaredpalmer jaredpalmer mentioned this pull request Apr 3, 2019
24 tasks
@jaredpalmer
Copy link
Owner Author

Does anyone actually need initialTouched?

@jaredpalmer jaredpalmer merged commit 4332637 into hooks Apr 26, 2019
@jaredpalmer jaredpalmer deleted the feature/initial-state branch April 26, 2019 13:34
@johnrom johnrom removed the v2 label May 27, 2019
@johnrom johnrom added this to the v2.0 milestone May 27, 2019
@ohmonster
Copy link

ohmonster commented Dec 10, 2019

I think I need initial touched. We have a use case where users may have address data saved on the server that doesn't meet our current validation field criteria --generally missing a phone number or something. Our error display rule triggers if the field is touched. So we want the form to be as populated as it can be, validated on mount, and touched on mount. -- We reuse the form, so we want this to happen conditionally as well. Ugh.

I was using a ref to do this before, but the upgrade to Formik 2.0 gave me errors about innerRefs.

geiralund added a commit to navikt/dagpenger-regel-ui that referenced this pull request Jun 3, 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.

None yet

6 participants