Using react-aria-components with react-hook-form and event handlers #4936
Unanswered
lloydjatkinson
asked this question in
Q&A
Replies: 2 comments 1 reply
-
I am not able to create a good reproduction in either codesandbox or stackblitz as they seem unable to find the react-aria-components typings. |
Beta Was this translation helpful? Give feedback.
0 replies
-
One way to "solve" this is to default to a react-hook-form controller which is really meant for when dealing with a component that doesn't forward refs - except that my component is. This works but feels like a lot of extra code - it would be great if the change handlers didn't require this. <Controller
name="exampleRequired"
control={control}
rules={{ required: { value: true, message: 'This is a required value' } }}
render={({ field }) =>
<TextField
{...field}
validationState={errors.exampleRequired ? 'invalid' : 'valid'}
errorMessage={errors.exampleRequired?.message} />} /> |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Hi,
I'm trying to use the react-aria-components text field with react-hook form. Unfortunately I have a type error and I'm not sure how to resolve it.
This is my text field wrapper:
Which I am then using like this in my form:
Which results in the following error:
I only have some vague ideas how to resolve this. I suspect it's because react-hook-form expects an event type whereas react-aria-components uses a plain string for the
onChange
.How should I best solve this?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions