RTK QUERY - UPDATE SEARCH RESULTS
Opened this issue · 5 comments
gaizkaeu commented
Describe the bug
I've followed the code sandbox from other issues I've seen. However I could't make it work. As It is explained I use a useState to store the data and update it.
Video
https://www.youtube.com/watch?v=4heSS5SHSQA
Isn't shown in the video, but all the requests to the api returned the same data as the first one.
const [trigger] = useLazySearchUserQuery();
const search_data: IUser[] = [];
const [items, setItems] = React.useState(search_data);
const handleOnSearch = (string) => {
console.log("the search is debounced!");
trigger({ first_name: string })
.unwrap()
.then((data) => {
setItems(data);
});
};
<ReactSearchAutocomplete
items={items}
onSearch={handleOnSearch}
resultStringKeyName="first_name"
onSelect={onSelect}
inputDebounce={600}
showIcon={false}
fuseOptions={{ keys: ["first_name"] }}
formatResult={formatResult}
/>
Thanks!
vyombangwal commented
getting the same error, the items state is updated but it is not reflecting in suggestions
mhcifci commented
ive got same issue any fix?
a4ajay36 commented
I'm also facing the same issue guys, Does anybody get the solution?
orelkakon commented
Someone solve this? Please help :(
Louis-Ramsey commented
@gaizkaeu did this work?