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

location.key in react-router-v4 #4336

Closed
Noitidart opened this issue Jan 14, 2017 · 9 comments
Closed

location.key in react-router-v4 #4336

Noitidart opened this issue Jan 14, 2017 · 9 comments

Comments

@Noitidart
Copy link
Contributor

I use the location.key in my child components.

The key is by default 6 characters long. For instance doing const history = createBrowserHistory(), then history.location` it looks like this:

Object { pathname: "/one", search: "", hash: "", query: null, key: "rjtd5t" }

However the location property received by children of <Match> looks like this:

Object { params: Object, isExact: true, pathname: "/one", location: Object, pattern: "/one/:pid?" }

location: Object { pathname: "/one", search: "", hash: "", query: null, state: null }

In this location object we see state but its null, I expcted it to be value of the key. Does anyone know if react router v4 plans to get this? Or if there is a way to get it in the props? I know of course I can get this key by going const history = createBrowserHistory(); let cur_key = history.location.key however this is may not match up with the props (due to animation timing etc), that's why I was hoping to get it from prop.

@mjackson
Copy link
Member

This is already fixed in the v4 branch.

@Noitidart
Copy link
Contributor Author

Noitidart commented Jan 14, 2017

Ah thank you @mjackson ! This is great news I'm really loving this. I am using ControlledBrowserRouter for Redux.

How can I get the fixed version of v4, do I have to wait till gets a release on npm? I am currently using v4.0.0-alpha.6. So in my package.json it looks like this:

  "dependencies": {
    "react-router": "^4.0.0-alpha.6",

@kwelch
Copy link
Contributor

kwelch commented Jan 18, 2017

You can be cutting edge but depending on the repo directly, until a new release is cut.

here is the syntax: git://github.com/user/project.git#commit-ish

I believe for this project it would be: git://github.com/ReactTraining/react-router#v4

@Noitidart
Copy link
Contributor Author

Thank you @kwelch ! Is there a scheduled release for alpha 7? The notes for alpha 6 say "do not use we have a huge update coming in the next couple of days".

@Noitidart
Copy link
Contributor Author

@kwelch may you please help me on how to install git://github.com/ReactTraining/react-router#v4 with npm? I am using create-react-app and was having difficulty. I really badly needed the location key.

@kwelch
Copy link
Contributor

kwelch commented Jan 30, 2017

See #4358, installing from git is not supported.

I was unaware additional steps were needed to allow for git dependencies and react-router does not support it.

@Noitidart
Copy link
Contributor Author

Oh dang thanks so very much for your fast replies! I am newbie to using non-UMD packages. Do you or @mjackson know when the release is for alpha7? The release notes for alpha6 said it was going to be a few days after the alpha6 release - https://github.com/ReactTraining/react-router/releases/tag/v4.0.0-alpha.6

@kwelch
Copy link
Contributor

kwelch commented Jan 30, 2017

@Noitidart The beta released today. Here are the docs.

https://reacttraining.com/react-router/

@Noitidart
Copy link
Contributor Author

Oh my gosh such perfect timing haha! Thank you @kwelch for that note!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 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