primary-violetP
Refine3y ago
6 replies
primary-violet

Autocomplete

<Controller
control={control}
name="status"
render={({ field }) => (
<Autocomplete
{...productAutocompleteProps}
{...field}
multiple
onChange={(, value) => {
if (Array.isArray(value)) {
field.onChange(value.map((p) => p.text ?? p));
} else {
field.onChange([]);
}
}}
getOptionLabel={(item) => {
return item?.text ? item.text : item;
}}
isOptionEqualToValue={(option, value) =>
value === undefined ||
option?.id?.toString() ===
(value?.id ?? value)?.toString()
}
renderInput={(params) => (
<TextField
{...params}
label={t("products.filter.status.label")}
placeholder={t("products.filter.status.placeholder")}
margin="normal"
variant="outlined"
size="small"
/>
)}
/>
)}
/>

help, it s saying that :

Type '{ multiple: true; onChange: (
: SyntheticEvent<Element, Event>, value: any[]) => void; getOptionLabel: (item: any) => any; isOptionEqualToValue: (option: any, value: any) => boolean; ... 9 more ...; filterOptions: (options: any[], state: FilterOptionsState<...>) => any[]; }' is not assignable to type 'AutocompleteProps<any, true, false, false, "div">'.
Types of property 'value' are incompatible.
Type '"ACTIVE" | "IN_ACTIVE"[]' is not assignable to type 'any[] | undefined'.
Type 'string' is not assignable to type 'any[]'.ts(2322)
Was this page helpful?