-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Controlled react-select input not being captured during submition #122
Comments
To be completely honest here I have never really looked into if Controller from react-hook-form works with this library, but what you can do is just not use it and use {isHydrated ? (
<ReactSelect
instanceId={id ?? generatedId}
components={{ Option: CustomOption }}
onChange={(newValue, actionMeta) => {
if (onChange) {
onChange(newValue, actionMeta)
// here
setValue(name, newValue)
}
field.onChange(newValue)
}}
value={field.value}
isSearchable={isSearchable}
isDisabled={disabled}
className={className}
{...rest}
/>
) : (
<div className="h-8 w-full animate-pulse rounded-md bg-gray-300" />
)} |
Hi there, I am having some issues with RHF Controller as well and would like to ask if it is supported and if not, what the advized alternative would be. The example below uses aria-components and is producing Code based on https://react-spectrum.adobe.com/react-aria/forms.html#react-hook-form <Controller
name="language.name"
control={control}
render={({ field, fieldState: { invalid, error } }) => (
<TextField {...field} isInvalid={invalid}>
<TextField.Label>Name</TextField.Label>
<TextField.Input {...register(field.name)} />
<TextField.FieldError>{error?.message} </TextField.FieldError>
</TextField>
)
}
/> |
FWIW RHF Controller works as expected, as long as we do not forget to pass |
i use remix-hook-fom in my project. I struggled trying to use it with React Select. here is my controlled React Select code:
and here is my implementation:
and here is my action:
when i try to
console.log
the value in the client, it is there as expected. but once i submit the form, it is not being captured in the action bygetValidatedFormData
and returns validation error. I try to debug it by adding.optional()
to the schema, it turns out that the data is empty. thebank
field didn't event sent to the action.before submitting this issue, i have tried all possible options in.
stringifyAllValues
as well as inpreserveStringified
, but nothing happens.in another remix roject where i use plain
useForm
withuseFormContext
from React Hook Form, it works just fine.The text was updated successfully, but these errors were encountered: