Added a dynamic title to the Content.jsx
This commit is contained in:
parent
6bbbd5c55d
commit
015b7dc529
@ -1,13 +1,21 @@
|
|||||||
import "./styles.sass";
|
import "./styles.sass";
|
||||||
import {routes} from "@/common/routes";
|
import {getByPath, routes} from "@/common/routes";
|
||||||
import {Route, Routes} from "react-router-dom";
|
import {Route, Routes, useLocation} from "react-router-dom";
|
||||||
|
import {useEffect} from "react";
|
||||||
|
|
||||||
export const Content = () => (
|
export const Content = () => {
|
||||||
<div className="content-wrapper">
|
const location = useLocation();
|
||||||
<Routes>
|
|
||||||
{Object.keys(routes).map((route) => (routes[route].map((route) => (
|
useEffect(() => {
|
||||||
<Route exact path={route.path} element={route.component}/>
|
document.title = "PowerTools - " + (getByPath(location.pathname)?.name || "404");
|
||||||
))))}
|
}, [location]);
|
||||||
</Routes>
|
|
||||||
</div>
|
return (
|
||||||
)
|
<div className="content-wrapper">
|
||||||
|
<Routes>
|
||||||
|
{Object.keys(routes).map((route) => (routes[route].map((route) => (
|
||||||
|
<Route exact path={route.path} element={route.component}/>
|
||||||
|
))))}
|
||||||
|
</Routes>
|
||||||
|
</div>);
|
||||||
|
}
|
Reference in New Issue
Block a user