remix-utils-rt
Version:
This package contains simple utility functions to use with [React Router](https://reactrouter.com/home).
29 lines (28 loc) • 1.08 kB
TypeScript
import type { FetcherWithComponents, SubmitFunction, SubmitOptions } from "react-router";
type SubmitTarget = Parameters<SubmitFunction>["0"];
/**
* Submits a HTML `<form>` to the server without reloading the page.
*/
type DebounceSubmitFunction = (
/**
* Specifies the `<form>` to be submitted to the server, a specific
* `<button>` or `<input type="submit">` to use to submit the form, or some
* arbitrary data to submit.
*
* Note: When using a `<button>` its `name` and `value` will also be
* included in the form data that is submitted.
*/
target: SubmitTarget,
/**
* Options that override the `<form>`'s own attributes. Required when
* submitting arbitrary data without a backing `<form>`. Additionally, you
* can specify a `debounceTimeout` to delay the submission of the data.
*/
options?: SubmitOptions & {
debounceTimeout?: number;
}) => void;
type DebouncedFetcher<Data = unknown> = Omit<FetcherWithComponents<Data>, "submit"> & {
submit: DebounceSubmitFunction;
};
export declare function useDebounceFetcher<Data>(): DebouncedFetcher<Data>;
export {};