sickdyd/react-search-autocomplete

RTK QUERY - UPDATE SEARCH RESULTS

Opened this issue · 5 comments

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}
          />

Screenshots
Screenshot 2022-12-07 at 19 58 46

Thanks!

getting the same error, the items state is updated but it is not reflecting in suggestions

ive got same issue any fix?

I'm also facing the same issue guys, Does anybody get the solution?

Someone solve this? Please help :(

@gaizkaeu did this work?