Replies: 1 comment
-
Definitely worth exploration. I hope As things stand today, I'm keeping my RFH wrapper as generic as possible and using that as a base for a form specific component (pass your form typed |
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.
-
Codesandbox: https://codesandbox.io/s/rhf-7-45-1-generic-sdx8hz
We have a generic components that use
useController
and you should only be able to use it with fields that arenumber
. Everything else works except that thefield.value
,useWatch
andfield.onChange
are not correctly typed. In reality I am not usinguseWatch
to monitor the value but I wanted to see if the problem is there too.As you can see in the following the types are incorrect. The type should be
number
but TS shows it isPathValue<TFieldValues, TPath>
.I think the problem is with
UseControllerProps
but I cannot figure out how do I change my component to let TS know that the value, onChange and useWatch all usenumber
while keeping the constraint that component can only be used with fields of typenumber
.Beta Was this translation helpful? Give feedback.
All reactions