saleor-dashboard/src/hooks/useLocationState.ts

18 lines
430 B
TypeScript

import { AppSections } from "@dashboard/new-apps/urls";
import { matchPath, useLocation } from "react-router";
const isAppPath = (pathname: string) =>
!!matchPath(pathname, {
path: `${AppSections.appsSection}:id`,
});
/*
* Use detailed information about the current location.
*/
export const useLocationState = () => {
const location = useLocation();
return {
isAppPath: isAppPath(location.pathname),
};
};