nuqs
Version:
Type-safe search params state manager for React - Like useState, but stored in the URL query string
46 lines (44 loc) • 1.38 kB
TypeScript
'use client';
import "../defs-mBb4lgVX.js";
import { AdapterOptions, AdapterProps } from "../context-DyUBtRzw.js";
import { ReactElement, ReactNode } from "react";
//#region src/adapters/testing.d.ts
type UrlUpdateEvent = {
searchParams: URLSearchParams;
queryString: string;
options: Required<AdapterOptions>;
};
type OnUrlUpdateFunction = (event: UrlUpdateEvent) => void;
type TestingAdapterProps = {
searchParams?: string | Record<string, string> | URLSearchParams;
onUrlUpdate?: OnUrlUpdateFunction;
rateLimitFactor?: number;
resetUrlUpdateQueueOnMount?: boolean;
children: ReactNode;
} & AdapterProps;
declare function NuqsTestingAdapter({
resetUrlUpdateQueueOnMount,
defaultOptions,
...props
}: TestingAdapterProps): ReactElement;
/**
* A higher order component that wraps the children with the NuqsTestingAdapter
*
* It allows creating wrappers for testing purposes by providing only the
* necessary props to the NuqsTestingAdapter.
*
* Usage:
* ```tsx
* render(<MyComponent />, {
* wrapper: withNuqsTestingAdapter({ searchParams: '?foo=bar' })
* })
* ```
*/
declare function withNuqsTestingAdapter(props?: Omit<TestingAdapterProps, "children">): ({
children
}: {
children: ReactNode;
}) => ReactElement;
//#endregion
export { NuqsTestingAdapter, OnUrlUpdateFunction, UrlUpdateEvent, withNuqsTestingAdapter };
//# sourceMappingURL=testing.d.ts.map