File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
src/routes/solid-router/reference/primitives Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : useResolvedPath
3+ ---
4+
5+ ` useResolvedPath ` retrieves a signal\< string\> .
6+ It contains the current resolved path as defined in the Route.
7+
8+ ``` js
9+ const path = useResolvedPath (() => ' ' );
10+
11+ // Parent Route path: /user/*
12+ console .log (path ()); // /user
13+
14+ const path = useResolvedPath (() => ' a/b/c' );
15+
16+ // Parent Route path: /user/*
17+ console .log (path ()); // /user/a/b/c
18+
19+ const path = useResolvedPath (() => ' /a/b/c' ); // Note: /
20+
21+ // Parent Route path: /user/*
22+ console .log (path ()); // a/b/c
23+ ```
24+
25+ Useful for making modular routers
26+
27+ ``` js
28+ const parentRoutePath = useResolvedPath (() => ' ' );
29+
30+ return <>
31+ < h1> Module component layer< / h1>
32+ < Router base= {parentRoutePath ()}> // Modular magic
33+ < Route path= " /" component= {() => < div> Index < / div> }/ >
34+ < Route path= " /a" component= {() => < div> AComponent< / div> }/ >
35+ < / Router>
36+ < / >
37+ ```
You can’t perform that action at this time.
0 commit comments