/[sudobot]/branches/7.x/docs/hooks/useRouter.tsx
ViewVC logotype

Annotation of /branches/7.x/docs/hooks/useRouter.tsx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 647 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 "use client";
2    
3     import { useRouterContext } from "@/contexts/RouterContext";
4     import { useRouter as useNextRouter } from "next/navigation";
5    
6     export default function useRouter() {
7     const { isChanging, setIsChanging } = useRouterContext();
8     const router = useNextRouter();
9    
10     return {
11     prefetch: router.prefetch,
12     back: router.back,
13     push(href, options) {
14     if (!isChanging) {
15     setIsChanging(true);
16     }
17    
18     router.push(href, options);
19     },
20     forward: router.forward,
21     refresh: router.refresh,
22     replace: router.replace,
23     } satisfies typeof router;
24     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26