Skip to content
Discussion options

You must be logged in to vote

Instead of clicking the you can use fetcher.submit to do the request.

function Search() {
  let fetcher = useFetcher<typeof loader>();
  let [query, setQuery]= useState("");
  let [debouncedQuery] = useDebounce(query, 300)

  useEffect(() => {
    if (debouncedQuery.length <= 2) return;
    fetcher.submit({ search: debouncedQuery })
  }, [debouncedQuery]);

  return (
    <>
      <fetcher.Form>
        <input
          type="search"
          name="search"
          value={query}
          onChange={(event) => setQuery(event.currentTarget.value)}
        />
      </fetcher.Form>

      <Typeahead
        isShown={true}
        isLoading={fetcher.state !== "idle"}
        data={fetcher.data

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mhuretski
Comment options

@kiliman
Comment options

@ChoaibMouhrach
Comment options

Answer selected by mhuretski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants