Replies: 1 comment
-
|
You need to pass a synthetic event shape: That said, for custom multi-value inputs like a checkbox list, <Controller
name="toppings"
control={control}
render={({ field }) => (
<MyInput
label="Pizza toppings"
value={field.value}
onChange={field.onChange}
/>
)}
/>No event object needed, no wrapping. Worth the extra lines. |
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.
-
I'm making a custom field, namely a checkbox list. Not a totally alien thing to build. Its value is an array of strings.
So when I pass it the destructed register function:
How is
MyInputexpected to call theonChangefunction that is now passed into the component?I've tried numerous ways to give it a target, a value, both, neither, I feel like I've tried everything.
Looking at the code, it blindly expects a
targetand atarget.name. So just passingonChange(newValue)isn't going to cut the mustard - it wants aevent.target.namegiveneventis the first argument. Even though this is hinted in the documented when using aControllercomponent. But I'm not. I find it too verbose.So what do I actually call
onChangewith please?Beta Was this translation helpful? Give feedback.
All reactions