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 support for generic components using FieldPathWithValue
#6562
✨ Add support for generic components using FieldPathWithValue
#6562
Conversation
cc @bluebill1049 @kotarella1110 and @barrymay since you were tagged as reviewers on my other PR.
Edit: Nvm, found a way! :) |
This reverts commit 2058b5b.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
let's wait for @barrymay and @kotarella1110's review feedback 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!!! 🙌
Please check my comments.
e2710df
@bluebill1049 Done! Sorry for the force-push which dismissed @kotarella1110 review! I usually rebase instead of merge so I was confused for a moment. But all good now! The diff of the merge commit is weird but I just moved a type I had called I also added expectations in my tests as @barrymay suggested. Since they were tests that just ensured everything was typed correctly, I just put basic expectations. |
Thanks for everyone's contribution and review. Let's do another patch release for all the bug fixes before release this as a new minor update. I will merge that once the patch goes out, there are still few small issues yet to be resolved. |
Just some thoughts, if this is a pattern that we all agree on, perhaps we can introduce something similar to |
@bluebill1049 Definitely something that can be applied to it too! |
DeepPartialImpl<UnionLike<T>>, | ||
FieldError | ||
>; | ||
type ControllerFieldError< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't pay close enough attention here, @kotarella1110 this was completely changed after the merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which potentially lead to this: #6679
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluebill1049 I don't understand the linked issue is talking about versions before this was merged right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeepMapImpl<DeepPartialImpl<UnionLike<TFieldValues>>, FieldError>
vs
DeepMap<DeepPartial<UnionLike<TFieldValues>>, FieldError>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still try to get my head around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok confirmed the latest definitely related for causing the issue, it could be related to the user's typescript version as well, as i couldn't reproduce the issue at the lib level but codesandbox with CRA, after omit TResult and the issue went away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to revert this one back guys, i don't have quick solution yet and it probably impact a lot of users. |
we can come back to this, I am sorry to roll this back but it's better not impact more users. |
I think we still want this awesome feature.
|
For clarity, switch RHF to 7.17.0 to see the issue. As you said, very strange this didn't come up in the test run. I agree this feature is very much worth trying to get right (and also worth ensuring our test runs can catch this too) |
I'm new to contributing but would love to help out with this. What can I do to get started on making this viable again? |
hope this can be reimplemented |
@julienfouilhe can you push and open this PR again? I think we can get this one back now. |
let's run that in the
https://github.com/react-hook-form/react-hook-form/releases/tag/v7.18.0-next.0 going to play more cautious with any TS-related update. |
See my note here about this issue: #6753 (comment) |
This seems like a better and much simpler API for the support of generic components than #6466
If the expected type is not specified to useController/
Controller
, then all possible types from theFieldValues
are returned.You can look at the test in
useController.test.tsx
for how it can be used.