I am trying to set the searchString into a state, but after typinbg 2 letters, the control is crashing.
Keep in mind this issue was not happening when I did not replace any components.
const [searchString, setSearchString] = useState<string>('');
searchString: string
): Promise<ProductOption[]> => {
setSearchString(searchString);
const productsResponse = await handleSearch(searchString);
const options = productsResponse.data.map<ProductOption>((p) => ({
value: p.id,
label: p.name,
image: p.image,
}));
totalItems = productsResponse.totalItems;
return options;
};```
`const Control = ({
children,
...props
}: ControlProps<ProductOption, false>) => (
<components.Control {...props}>
<Search className='ms-2' /> {children}
</components.Control>
);
`
I am trying to set the searchString into a state, but after typinbg 2 letters, the control is crashing.
Keep in mind this issue was not happening when I did not replace any components.
const [searchString, setSearchString] = useState<string>('');