Autocomplete - Is it possible to use Autocomplete with react-form-hook? #5298
Answered
by
wingkwong
dinbtechit
asked this question in
Q&A
-
|
Autocomplete - Is it possible to use Autocomplete with react-form-hook? <Controller
control={control}
name="category"
render={({
field: { onBlur, onChange, value, ref },
fieldState: { invalid, error },
}) => (
<Autocomplete
ref={ref}
defaultInputValue={value}
errorMessage={error?.message}
isInvalid={isInvalid}
isLoading={isSearching}
label="Category"
startContent={
<Search className="text-black/50 dark:text-white/90 text-slate-400 scale-[0.90] pointer-events-none" />
}
value={value}
onBlur={onBlur}
onChange={onChange}
onInputChange={(value) => {
searchCategory(value);
}}
>
{categorySuggestions.map((it) => (
<AutocompleteItem key={it.label} className="capitalize">
{it.label}
</AutocompleteItem>
))}
</Autocomplete>
)}
rules={{
required: "Category is required",
}}
/> |
Beta Was this translation helpful? Give feedback.
Answered by
wingkwong
May 16, 2025
Replies: 1 comment 2 replies
-
|
selectedKey={field.value}
onSelectionChange={field.onChange} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dinbtechit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
defaultInputValue,valueandonChangeare uncontrolled. You should just useselectedKeyandonSelectionChange(which are controlled) instead.