init commit,
This commit is contained in:
21
03_source/frontend/src/routes/hooks/use-router.ts
Normal file
21
03_source/frontend/src/routes/hooks/use-router.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export function useRouter() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const router = useMemo(
|
||||
() => ({
|
||||
back: () => navigate(-1),
|
||||
forward: () => navigate(1),
|
||||
refresh: () => navigate(0),
|
||||
push: (href: string) => navigate(href),
|
||||
replace: (href: string) => navigate(href, { replace: true }),
|
||||
}),
|
||||
[navigate]
|
||||
);
|
||||
|
||||
return router;
|
||||
}
|
Reference in New Issue
Block a user