Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get params outside of a component #3015

Closed
misterwilliam opened this issue Feb 2, 2016 · 3 comments
Closed

Get params outside of a component #3015

misterwilliam opened this issue Feb 2, 2016 · 3 comments

Comments

@misterwilliam
Copy link

I would like to retrieve the current params outside of a component, and as far as I can tell React Router does not provide a convenient way of doing that.

Sometime back before 0.13 the router had getCurrentParams() which is what I used to use.

Now the best thing I can figure out is:

// Copy and past contents of PatternUtils into my project
var PatternUtils = require('<copy of PatternUtils.js>')

const { remainingPathname, paramNames, paramValues } =
   PatternUtils.matchPattern(
       "<copy of path pattern with params I am interested in>",    
   window.location.pathname);

This is pretty ugly, and I was hoping for a more elegant solution.

@taion
Copy link
Contributor

taion commented Feb 2, 2016

Thanks for your question!

We want to make sure that the GitHub issue tracker remains the best place to track bug reports and feature requests that affect the development of React Router.

Questions like yours deserve a purpose-built Q&A forum. Could you post this question to Stack Overflow with the tag #react-router? https://stackoverflow.com/questions/ask?tags=react-router

We also have an active and helpful React Router community on Reactiflux, which is a great place to get fast help with React Router and with the rest of the React ecosystem. You can join at https://discord.gg/0ZcbPKXt5bYaNQ46.

@taion taion closed this as completed Feb 2, 2016
@kuudihxquuwhxq
Copy link

I found the question that the issue opener posted: https://stackoverflow.com/questions/35160459/get-params-outside-of-a-component. However, there's no response after 2 weeks and I'd like to be able to access params outside of components as well. I'm finding a lot of info on doing this with react-router verion < 2.0, but none with 2.0.

@kuudihxquuwhxq
Copy link

After some more digging, this appears to be an open issue (#2547) and is unresolved so far.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants