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.

Is nested path params supported?

See original GitHub issue

Trying to simulate the URL structure like github.com I’ve got these routes:

const routes = {
	'/': () => <Home />,
	'/user': () => <User />,
	'/user/:repo': () => <Repo />,
	'/user/:repo/issues': () => <Issues />,
	'/user/:repo/issues/:issue_id': () => <Issue />,
}

I expect <Issue /> shall be invoked and shown on screen when I visit :

http://localhost:5173/user/repo_foobar/issues/222

and I could access issue_id (which should be 222) like this:

const [path, pairs] = usePathParams('/user/:repo/issues/:issue_id')

But for some reasons <Issue /> never showed on screen.

Did I miss something in the route config?

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
n33pmcommented, Nov 7, 2022

These are only legal and supported URL characters but there is no need do support these characters in the route matcher.

In my humble opinion keep it simple. each additional character ( route matcher ) can lead to unexpected problems.

0reactions
coodoocommented, Nov 8, 2022

Actually I agree with everyone here on keeping it simple is good, also not supporting _ is really not that of a big deal, just make sure to note that in the doc so future users know ahead of time! 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can you include path parameters in nested router w
When you include the APIRoute to the app instance, it will evaluate all routes and appends them from your dedicated APIRoute to the...
Read more >
Path Parameters - FastAPI
OpenAPI doesn't support a way to declare a path parameter to contain a path inside, as that could lead to scenarios that are...
Read more >
Detect path parameter type for nested routes from ... - GitHub
To create nested Viewsets, I'm using https://github.com/alanjds/drf-nested-routers Route registration happens like this: router ...
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 >
Nested query | Elasticsearch Guide [8.5] | Elastic
You can search nested fields using dot notation that includes the complete path, such as obj1.name . Multi-level nesting is automatically supported, and ......
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