Skip to content

Commit

Permalink
fix type params
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Sep 9, 2024
1 parent bd29bef commit ac44969
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/hooks/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,23 @@ import {
type TryValidateSyncRT,
} from "../utils/schema"

export type Navigate<State extends Record<string, any> = Record<string, any>> =
{
(
to: To,
options?: Omit<NavigateOptions, "state"> & {
state?: State & Partial<PageState>
next?: boolean
},
): void
(delta: number): void
}
export type Navigate = {
<State extends Record<string, any> = Record<string, any>>(
to: To,
options?: Omit<NavigateOptions, "state"> & {
state?: State & Partial<PageState>
next?: boolean
},
): void
(delta: number): void
}

export function useNavigate<
State extends Record<string, any> = Record<string, any>,
>(): Navigate<State> {
export function useNavigate(): Navigate {
const navigate = _useNavigate()
const searchParams = useSearchParams()

return (
toOrDelta,
toOrDelta: To | number,
options: (NavigateOptions & { next?: boolean }) | undefined = undefined,
) => {
if (typeof toOrDelta === "number") navigate(toOrDelta)
Expand Down

0 comments on commit ac44969

Please sign in to comment.