Skip to content

Commit

Permalink
Add support for useFetcher options in useDebounceFetcher (#429)
Browse files Browse the repository at this point in the history
Enhance the useDebounceFetcher hook by adding support for passing a key
to the underlying useFetcher function. This addition simplifies the
identification of fetchers within a global context.

Co-authored-by: Sergio Xalambrí <[email protected]>
  • Loading branch information
leskraas and sergiodxa authored Jan 20, 2025
1 parent f06f342 commit 0963192
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/react/use-debounce-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type DebouncedFetcher<Data = unknown> = Omit<
"submit"
> & { submit: DebounceSubmitFunction };

export function useDebounceFetcher<Data>() {
export function useDebounceFetcher<Data>(opts?: Parameters<typeof useFetcher>[0],) {
let timeoutRef = useRef<Timer>(null);

useEffect(() => {
Expand All @@ -45,7 +45,7 @@ export function useDebounceFetcher<Data>() {
};
}, []);

let fetcher = useFetcher<Data>() as DebouncedFetcher<Data>;
let fetcher = useFetcher<Data>(opts) as DebouncedFetcher<Data>;

// Clone the original submit to avoid a recursive loop
const originalSubmit = fetcher.submit;
Expand Down

0 comments on commit 0963192

Please sign in to comment.