UNPKG

@zextras/carbonio-shell-ui

Version:

The Zextras Carbonio web client

19 lines 796 B
"use strict"; /* * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com> * * SPDX-License-Identifier: AGPL-3.0-only */ Object.defineProperty(exports, "__esModule", { value: true }); exports.useCurrentRoute = void 0; const react_1 = require("react"); const lodash_1 = require("lodash"); const react_router_dom_1 = require("react-router-dom"); const app_1 = require("../store/app"); const useCurrentRoute = () => { const location = (0, react_router_dom_1.useLocation)(); const routes = (0, app_1.useRoutes)(); return (0, react_1.useMemo)(() => (0, lodash_1.find)(routes, ({ route }) => (0, lodash_1.startsWith)((0, lodash_1.trim)(location.pathname, '/'), route)), [location.pathname, routes]); }; exports.useCurrentRoute = useCurrentRoute; //# sourceMappingURL=hooks.js.map