From dfe71f37d7937d80b73a3db5a2bbcac5d66348ff Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 9 Jul 2023 18:22:22 +0200 Subject: [PATCH] The Root.jsx now updates the page title --- src/common/layouts/Root/Root.jsx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/common/layouts/Root/Root.jsx b/src/common/layouts/Root/Root.jsx index 9a04e9c..60dde8d 100644 --- a/src/common/layouts/Root/Root.jsx +++ b/src/common/layouts/Root/Root.jsx @@ -1,15 +1,28 @@ import Navigation from "@components/Navigation"; -import {Outlet} from "react-router-dom"; +import {Outlet, useLocation} from "react-router-dom"; import {Box, Toolbar} from "@mui/material"; import Footer from "@components/Footer"; +import {useEffect} from "react"; +import routes from "@/common/routes"; +import footerRoutes from "@/common/routes/footer.jsx"; -export const Root = () => <> - +export const Root = () => { + const location = useLocation(); - - - + useEffect(() => { + [...routes, ...footerRoutes].forEach(route => { + if (route.path === location.pathname) document.title = `LicenseAPI - ${route.name}`; + }); + }, [location]); -