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.

Params is empty on root path

See original GitHub issue

Version

react-router-dom: 4.1.1 react-router-config: ^1.0.0-beta.4

Test Case

https://codesandbox.io/s/j14yvr4rr9

Steps to reproduce

navigate to ‘organisation info’

Expected Behavior

params.organisationGuid in Home component is ‘some-organisation-guid’

Actual Behavior

params.organisationGuid in Home component is ‘undefined’

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
timdorrcommented, Jan 23, 2018

That is logically impossible. You can have <Route>s anywhere in your tree, with their own arbitrary params. There is not one canonical representation of the current <Route> and therefore the current match, only what is closest in the ancestor chain. We no longer have the concept of a central route config.

2reactions
goodbombcommented, Jan 22, 2018

@timdorr I really believe that this should be considered a bug. Not having the params available as a global object seems like a total anti-pattern, considering the URL is available globally. If I have a breadcrumbs component that exists across the entire application and it needs to be able to fetch data on occasion, I have to parse the URL manually when IMO it should inherently be possible while using the router.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Params is empty on root path - remix-run/react-router - GitHub
This is expected. params are not global, so they're not available to the ancestor components in the tree where the match occurs.
Read more >
The route params is empty - angular - Stack Overflow
However if I add the parent_id I am routing to the root probably because app.routes already defineds :id parameter which is needed in...
Read more >
ActivatedRoute - Angular
Provides access to information about a route associated with a component that is loaded in an outlet. Use to traverse the RouterState tree...
Read more >
How to handle empty route parameters : r/expressjs - Reddit
Hi Im trying to handle an empty route parameter if a path is not specified , I would like to return a new...
Read more >
Params field is empty in $router.push - Laracasts
Hi there, I use this this.$root.$router.push({ path: '/dashboard', params: { errors: 'error' }, query: { test: 'test' } }) in my component to...
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