diff --git a/src/main.ts b/src/main.ts index 96848f0..2bc5bae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ export type { Routes, RouteOptionParams, PathParamOptions } from './router' export { RouterProvider } from './context' export { useRedirect, Redirect } from './redirect' -export type { RedirectProps, UseRedirectProps } from './redirect' +export type { RedirectProps } from './redirect' export { Link, ActiveLink } from './Link' diff --git a/src/redirect.ts b/src/redirect.ts index 4bdac12..74a2e4b 100644 --- a/src/redirect.ts +++ b/src/redirect.ts @@ -2,21 +2,13 @@ import { useLayoutEffect } from 'react' import { getCurrentHash, usePath } from './location' import { navigate, NavigateOptions } from './navigate' -import { QueryParam, useQueryParams } from './querystring' +import { useQueryParams } from './querystring' export interface RedirectProps extends NavigateOptions { to: string merge?: boolean } -export interface UseRedirectProps { - predicateUrl: string - targetUrl: string - queryParams?: QueryParam | URLSearchParams - replace?: boolean - state?: unknown -} - export function Redirect({ to, query, @@ -28,15 +20,14 @@ export function Redirect({ return null } +export interface UseRedirectOptions extends NavigateOptions { + merge?: boolean +} + export function useRedirect( predicateUrl: string | null, targetUrl: string, - { - query, - replace = true, - merge = true, - state, - }: { query?: QueryParam; replace?: boolean; merge?: boolean; state?: unknown } = {}, + { query, replace = true, merge = true, state }: UseRedirectOptions = {}, ): void { const currentPath = usePath() const [currentQuery] = useQueryParams()