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.

Getting params in wrapped/nested routes

See original GitHub issue
import { Outlet } from "solid-app-router";

function PageWrapper () {
  return <div>
    <h1> We love our users! </h1>
    <Outlet/>
    <Link href="/">Back Home</Link>
  </div>
}

<Route path="/users" element={<PageWrapper/>}>
  <Route path="/" element={<Users/>} />
  <Route path="/:id" element={<User/>} />
</Route>

In this example, it seems that there is no way to get the “id” parameter from within the PageWrapper component. This is, as far as I can tell, due to parameters not being held by the global Router context, but rather the local Route context. Are there any workarounds for this?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
EthanYidongcommented, Jun 2, 2022

If this is not intended, I am open to creating a pull request for this, however, changing the current behavior of useParams to pull from the global router may break some code which expects to only get parameters from the current Route context provider. To avoid that, should I create a new function such as useGlobalParams?

0reactions
ryansolidcommented, Nov 21, 2022

Any one interested in this willing do a little leg work for me? We made a choice that seemed sensible, mostly that this decision might lead us to a path where we’d need to reactively account for things that don’t exist. Ie… have to use proxies. Seemed sort of dangerously leaky. But I’d consider it if this was pretty standard. So do other client routers allow this?

The next thing I’d be doing is looking at React Router, Tanstack Router, Next Router, Sveltekit Router, Nuxt Router, etc… and determining if they had this functionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested routes and parameters · Issue #854 - GitHub
Hello,. I'm having an issue creating nested routes where the parent route contains a parameter. This is my desired end result:.
Read more >
Overriding params in nested routes - ruby on rails
I want my routes to look like :user_id/:project_id/:issue_id and I want it to be consistent for all the models.
Read more >
How to Use Nested Routes in React Router 6
Nested Routes and useParams​​ In the <Post /> component we can get the parameter 123 by importing useParams. Then in the body of...
Read more >
React Router 6 Tutorial #4 - Nested Routes - YouTube
Get access to premium courses on Net Ninja Pro:https://netninja.dev/courses My Udemy ...
Read more >
Advanced routing • Docs • SvelteKit
If you want to render the nested error page, you should create a route ... You can do that by wrapping the parameter...
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