mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 08:09:33 +01:00
* [WEB-5473] fix: source map errors * [WEB-5473] chore: run codemod * fix: build errors in editor --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
33 lines
880 B
TypeScript
33 lines
880 B
TypeScript
import { useMemo } from "react";
|
|
import { useLocation, useNavigate, useSearchParams as useSearchParamsRR } from "react-router";
|
|
import { ensureTrailingSlash } from "./helper";
|
|
|
|
export function useRouter() {
|
|
const navigate = useNavigate();
|
|
return useMemo(
|
|
() => ({
|
|
push: (to: string) => navigate(ensureTrailingSlash(to)),
|
|
replace: (to: string) => navigate(ensureTrailingSlash(to), { replace: true }),
|
|
back: () => navigate(-1),
|
|
forward: () => navigate(1),
|
|
refresh: () => {
|
|
location.reload();
|
|
},
|
|
prefetch: async (_to: string) => {
|
|
// no-op in this shim
|
|
},
|
|
}),
|
|
[navigate]
|
|
);
|
|
}
|
|
|
|
export function usePathname(): string {
|
|
const { pathname } = useLocation();
|
|
return pathname;
|
|
}
|
|
|
|
export function useSearchParams(): URLSearchParams {
|
|
const [searchParams] = useSearchParamsRR();
|
|
return searchParams;
|
|
}
|