V7 types no longer recognise overlaps makes it difficult to extract reusable components #4682
Unanswered
cabbiepete
asked this question in
General
Replies: 1 comment
-
I asked same question here #4672, jfyi |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With V7 this sandbox shows how we have to pass the TFieldValues type through every component.
This results in errors like
Type 'Control<{ email: string; password: string;}>' is not assignable to type 'Control<{ email: string; }>'
even though clearly there is an overlap.Form:
https://codesandbox.io/s/mystifying-lichterman-w1h45?file=/src/ExampleForm.tsx
Component:
https://codesandbox.io/s/mystifying-lichterman-w1h45?file=/src/ControlledTextField.tsx
If we do not pass the FormFields type through we get mis-matches for any of the UseFormReturn items.
Perhaps this is a worthy tradeoff? If any of the maintainers could weigh in on that I'd much appreciate it.
And secondly I wanted to setup this example for reference for anyone else in the same boat :-) perhaps would be good to get a cut down (no next.js) example in the examples directory? If you agree I can do a PR.
Beta Was this translation helpful? Give feedback.
All reactions