question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with navigation and nested routes

See original GitHub issue

Hi, I’ve found some strange problems with navigation when you are using nested routes with params. I’m testing with the latest version 1.4.

How to reproduce?

Here is the link to the reproduction code: https://stackblitz.com/edit/react-raviger-test?file=index.js

Press on the links in the bottom part in that order to:

  1. nested with a param About (the route is loaded)
  2. nested with a param Test (the route is not loaded)
  3. root (the route is loaded)
  4. nested with a param Test (the route is loaded)
  5. root (the route is loaded)
  6. nested with a param Test (the route is loaded)
  7. nested with a param About (the route is not loaded)

raviger-bug

Possible cause

I’ve checked many things, and I think the useLocationChange hook is the main suspect. It looks like the if condition with inheritBasePath option is causing the problem. I haven’t found any other place where this option is used internally.

I was trying to debug the code with breakpoints in browser devtools. After setting the value of basePath to what is provided with options the issue is gone: inheritBasePath-hack raviger-fixed

Do you reckon we could somehow fix this behaviour? Maybe we just need to remove the inheritBasePath condition 😄 or force the false value when using hook internally from the useRoutes hook?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kyeoticcommented, Apr 28, 2020

@macku I released a beta which hopefully addresses this, see #51 for details

1reaction
kyeoticcommented, Apr 28, 2020

fix publishes under 1.4.1

Thanks for all the research on this @macku, you made it a breeze to fix 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested Routing Not Working in React Router v6 - Stack Overflow
First, fix the invariant warning for the nested route you are trying to match. You rendered descendant `<Routes>` (or called `useRoutes()`) ...
Read more >
Problem with using "navigateBack" with nested routes. Admin ...
Hello there, so I'm trying to get something similar to an Admin Dashboard working with Flutter (really not fun so far.
Read more >
The Guide to Nested Routes with React Router - ui.dev
In this comprehensive, up-to-date guide, you'll learn everything you need to know about creating nested routes with React Router.
Read more >
React Router 6: Nested Routes - Robin Wieruch
Nested Routes are a powerful feature. While most people think React Router only routes a user from page to page, it also allows...
Read more >
Nested Routes | Vue Router
This will ensure navigating to /user/:id will always display the nested route. In some scenarios, you may want to navigate to a named...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found