You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then when i use this TestableController component in place of the Controller component, i get a TS build error on the control prop using the control from useFormContext:
import{TestableController}from"./TestableController";import{useFormContext,Controller}from"react-hook-form";import{Fields}from"./LandingPage";exportdefaultfunctionFormSection(){const{ control }=useFormContext<Fields>();return(<divclassName="App"><TestableControllername="foo"control={control}// 🔴 build errorrender={({ field })=>(<labelhtmlFor={field.name}>
foo:
<br/><input{...field}type="text"/></label>)}/>
...
</div>
the build error is:
Type 'Control<Fields, any>' is not assignable to type 'Control<FieldValues, any>'.
The types of '_options.resolver' are incompatible between these types.
Type 'Resolver<Fields, any>' is not assignable to type 'Resolver<FieldValues, any>'.ts(2322)
is there some typing magic i can apply here to fix this?
This discussion was converted from issue #11071 on October 19, 2023 11:18.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm swizzling the
Controller
component to do some simple wrapping:then when i use this
TestableController
component in place of theController
component, i get a TS build error on thecontrol
prop using thecontrol
fromuseFormContext
:the build error is:
is there some typing magic i can apply here to fix this?
live example:
https://codesandbox.io/s/confident-khayyam-ysqxtz?file=/src/FormSection.tsx:333-359
version:
7.43.9
Originally posted by @json2d in #10777
Beta Was this translation helpful? Give feedback.
All reactions