/** * > [!NOTE] * > Install using `bunx shadcn@latest add @remix-utils/existing-search-params`. * * ```ts * import { ExistingSearchParams } from "remix-utils/existing-search-params"; * ``` * * > [!NOTE] * > This depends on `react` and `react-router` * * When you submit a GET form, the browser will replace all of the search params in the URL with your form data. This component copies existing search params into hidden inputs so they will not be overwritten. * * The `exclude` prop accepts an array of search params to exclude from the hidden inputs * * - add params handled by this form to this list * - add params from other forms you want to clear on submit * * For example, imagine a table of data with separate form components for pagination and filtering and searching. Changing the page number should not affect the search or filter params. * * ```tsx *
* ``` * * By excluding the `page` param, from the search form, the user will return to the first page of search result. * * ```tsx * * ``` * * @author [Sergio XalambrÃ](https://sergiodxa.com) * @module Component/Existing Search Params */ import * as React from "react"; type Props = { /** * These query params will not be included as hidden inputs. * - add params handled by this form to this list * - any params from other forms you want to clear on submit */ exclude?: Array