UNPKG

@kentcdodds/tmp-remix-utils

Version:

This package contains simple utility functions to use with [Remix.run](https://remix.run).

37 lines (36 loc) 1.13 kB
import type { SubmitOptions, FetcherWithComponents, SubmitFunction, } from "@remix-run/react"; 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 {};