Early issue with nested `useRoutes`
See original GitHub issueSorry for the vague issue but I just thought I would give you a heads up while investigating.
Since upgrading to 1.0.0-rc.3 (Also tried rc6) we have been having issues with previously working nested useRoutes.
The basic structure of our app is as follow
An “App” with useRoutes that either maps to a list page or a view entity page
basePath is foo/bar/entities
Routes are similar to the following
const routes = {
'/': () => <ListPage />,
'/:id/*': ({ id }) => (
<ViewPage id={id} />
),
}
A view entity page with useRoutes that maps to 3 tabs within the page,
basePath is foo/bar/entities/<id> where id is a numeric id.
Routes are similar to the following
const routes = {
"/tab1": () => <Component1 />,
"/tab2": () => <Component2 />,
"/tab3": () => <Component3 />
}
Previously (0.5.8) we were using usePath within one of the tabs (so 2 useRoutes deep) with no problems, it would always return the path we expected (/tab2)
Now however, if you land on tab2 (i.e. start a new browser tab at the url foo/bar/entities/1/tab2) usePath will return the correct value (/tab2)
But as soon as you navigate to a different tab usePath (called within the tab) starts returning /1/<tabNo>. The basepath in the context is correct (has the id at the end of the path), but it’s like it calculated the path based on the basePath of the router one level higher.
context = { path: '/1/tab2', basePath: 'foo/bar/entities/1' }
I’ll keep adding detail to this issue as I investigate, but I thought it might be possible you have an idea what’s going on.
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)

Top Related StackOverflow Question
Bugs happen but great support from maintainers is rare! We all appreciate very much the effort you put in making sure that your library is top notch. Kudos to you @kyeotic!
@micmcg I’ve got a fix, will be publishing under
1.0.0-rc.7.the
useLocationChangerefactor has introduced several issues which testing hasn’t caught. I will need to improve test coverage before I can promote the release candidate to final. I appreciate you guys sticking with me through all the bugs this week.I did add a test that was failing prior to this fix.