Formik: Form elements are throwing errors after upgrade to v2

Created on 25 Oct 2019  ·  7Comments  ·  Source: formium/formik

🐛 Bug report

Current Behavior


All <Form> elements are throwing type errors after upgrading to v2

image

Expected behavior


Per the upgrade/migration docs nothing should have changed to cause this to happen, no type errors should exist.

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 2.0.1
| React | 16.11.0
| TypeScript | 3.6.4

Most helpful comment

Releasing it right now

All 7 comments

@rathpc This appears to be our fault looking back at the Breaking Changes for rc-15

Please read my write-up in #1927

From rc-15 onwards, Form started being declared as a const and having its type determined by the result of React.forwardRef<HTMLFormElement>:

https://github.com/jaredpalmer/formik/blob/dd7b36601f7820db049082e60c40b773fe9a2219/src/Form.tsx#L13

But the returned type does not include all needed props, we also need to add the React 'form' component props. See the link below to my forked copy of the repo with what worked for me.

https://github.com/pealmeid/formik/commit/62ceae6337cda185d1537f4a108690ad27762629#diff-ed26553f90767261033a693ebcd450b0

As I'm relatively new to React and Formik, any feedback on the correctness of this solution is greatly appreciated.

Regards.

I am in bed trying to fall asleep at 1am, so I may be missing something.

I see the change - as far as the “correctness” I don’t see an issue.

The issue I reproduced was with useField - I am not sure how this would
have cascaded its way down to that hook, I simply downgraded my codebase so
I never did check the internals, but I think the solution you have proposed
is part of the second breaking change noted in the change log for RC15 (not
the field based breaking change)

The idea in the change log is to allow for more use cases of the props and
my concern is whether any changes we make removed the added flexibility
with the new typings

Just something to look out for as you try to submit a PR

This also just so happens to be a non-tested part of Formik - so any non
typing based changes definitely would preferably warrant an experienced
maintainer to approve

On Sat, Oct 26, 2019 at 12:54 AM Pedro Almeida notifications@github.com
wrote:

From rc-15 onwards, Form started being declared as a const and having its
type determined by the result of React.forwardRef:

https://github.com/jaredpalmer/formik/blob/dd7b36601f7820db049082e60c40b773fe9a2219/src/Form.tsx#L13

But the returned type does not include all needed props, we also need to
add the React 'form' component props. See the link below to my forked
copy of the repo with what worked for me.

pealmeid@62ceae6#diff-ed26553f90767261033a693ebcd450b0
https://github.com/pealmeid/formik/commit/62ceae6337cda185d1537f4a108690ad27762629#diff-ed26553f90767261033a693ebcd450b0

As I'm relatively new to React and Formik, any feedback on the correctness
of this solution is greatly appreciated.

Regards.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jaredpalmer/formik/issues/1926?email_source=notifications&email_token=ABKAJHMUEXBI2XIII4D3IOTQQPEPRA5CNFSM4JFJOHF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECJ7WVA#issuecomment-546569044,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABKAJHIIRWHKKX4FBYYPUS3QQPEPRANCNFSM4JFJOHFQ
.

>

Mahdi Hussein | CEO/Founder
[email protected] | Cell: 772.486.1172 <+17724861172> | LinkedI
https://www.linkedin.com/in/mahdi-hussein-564a0711bn
https://www.linkedin.com/in/mahdi-hussein-564a0711b
Articles https://petrooutlet.com/blog/authors/mahdi-hussein |
petrooutlet.com | 1-800-791-TECH <+18007918324>

Hello, can we expect this to be released in a 2.0.3 soon ?

This seems to be resolved by https://github.com/jaredpalmer/formik/pull/1931 so just waiting on a patch release. Thank you!

Releasing it right now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jordantrainor picture jordantrainor  ·  3Comments

PeerHartmann picture PeerHartmann  ·  3Comments

najisawas picture najisawas  ·  3Comments

outaTiME picture outaTiME  ·  3Comments

pmonty picture pmonty  ·  3Comments