useResolvedPath
Edit this pageuseResolvedPath retrieves a signal<string>.
It contains the current resolved path as defined in the Route.
const path = useResolvedPath(() => "");
// Parent Route path: /user/*console.log(path()); // /user
const path = useResolvedPath(() => "a/b/c");
// Parent Route path: /user/*console.log(path()); // /user/a/b/c
const path = useResolvedPath(() => "/a/b/c"); // Note: /
// Parent Route path: /user/*console.log(path()); // a/b/cUseful for making modular routers
const parentRoutePath = useResolvedPath(() => "");
return ( <> <h1>Module component layer</h1> <Router base={parentRoutePath()}> {" "} // Modular magic <Route path="/" component={() => <div>Index</div>} /> <Route path="/a" component={() => <div>AComponent</div>} /> </Router> </>);