molefrog / wouter

🥢 A minimalist-friendly ~2.1KB routing for React and Preact
https://npm.im/wouter
The Unlicense
6.41k stars 146 forks source link

break out of nest and keep base #459

Closed huanent closed 4 weeks ago

huanent commented 4 weeks ago

Hi I have this route config

<Router base="/admin">
    <Route path="/account" nest>
        <Route path="/login"/>
    <Route>
    <Route path="/home" nest>
        <Route path="/projects"/>
    <Route>
</Router>

I would like jump to /admin/home/projects from /admin/account/login, so I need use setLocation('~/admin/home/projects') Is there a way to keep base and break out of nest? like setLocation('@/home/projects') -->"/admin/home/projects"

molefrog commented 4 weeks ago

No, there is no way to make it work like that at the moment. Actually, <Route nest> internally creates a new Router with a special base prop, so we can't really distinguish between nested routes and routers with base attribute. The ~ modifier only works with top-level paths.

huanent commented 4 weeks ago

I understand. Thank you for your answer.