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

resetForm handler doesn't work same at formik 2 version #2034

Closed
krailler opened this issue Nov 14, 2019 · 5 comments
Closed

resetForm handler doesn't work same at formik 2 version #2034

krailler opened this issue Nov 14, 2019 · 5 comments
Labels

Comments

@krailler
Copy link
Contributor

krailler commented Nov 14, 2019

🐛 Bug report

With formik 1, when we use resetForm handler and we don't pass nextValues, it uses initialValues from props. You can see this behavior in https://github.com/jaredpalmer/formik/blob/version-1.5.8/src/Formik.tsx#L532

But, with formik 2, when we use resetForm handler and we don't pass nextValues, it uses initialValues from a ref and this ref is only updated when the initialValues changes and the variable enableReinitialize is true. You can see this behavior in https://github.com/jaredpalmer/formik/blob/master/src/Formik.tsx#L362

Current Behavior

resetForm handler uses initialValues from ref using formik 2.

Expected behavior

Use initialValues from props when we use resetForm handler, same as formik 1.

Suggested solution(s)

I don't know if this is an issue or the correct behavior. I need to know if the formik 1 resetForm behavior is the correct (And fix it in formik 2) or the actual behavior is correct and it's a bug with formik 1.

Additional context

Your environment

Software Version(s)
Formik 2.0.4
React 16.11.0
TypeScript 3.7.2
Browser Google Chrome 78.0.3904.97 (64-bit)
npm/Yarn npm 6.12.0
Operating System macOS Catalina 10.15
@AlberErre
Copy link

AlberErre commented Nov 20, 2019

I'm having the same issue, any news about this?

@krailler
Copy link
Contributor Author

Hi @jaredpalmer, can you see this, please? 🙏

@akonyer
Copy link

akonyer commented Jan 2, 2020

I'm trying to upgrade to formik v2.0 and I'm having the same error. I think until this is sorted out I have to revert back to v1 for now

@jaredpalmer
Copy link
Owner

Can you submit a PR?

@swyxio
Copy link

swyxio commented Sep 15, 2020

should close since PR merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants