-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
React Router is uncontrolled with respect to query state #4889
Comments
When you navigate within React Router, you pass a location string or object to the I'm having a hard time understanding the issue that you're having, but there shouldn't be a problem with components not updating because only the If I'm missing something, please include some example code. |
thank you @pshrmn! It took me a while but I found a way to replicate: http://codepen.io/anon/pen/vxvQdN. I changed |
Oh whoops. I merely broke your example. My apologies. I will continue trying. |
Okay, I am back to explain myself :). First, thanks again @pshrmn for your reply and your demo code. Not sure why I didn't do this. Where do I send the check? I took a deep dive and I identified my problem. The issue was related to my transition from v4-beta.5 to v4.0.0. I had made the transition, didn't notice the transition broke everything, and then assumed the issue was just with query strings, which I had just then tried using for the first time in this app! But here is what happened: In beta 5, In v4.0.0, Thanks again for your response, and sorry for posting this inane issue! |
Oh, sorry, I probably could have saved you some time if I had included the link to the blocked updates guide. I think that when I was originally writing my response, I included it, but since you mentioned I'm working on putting together a FAQ and the blocked updates problem is at the top of the list, so hopefully fewer people will be running into the same issue as time goes on. |
Well I'm glad I finally dug into this codebase. I last looked at version 3, which I never got my head around. This version was basically immediately approachable due to the React idiomatic approach. So at least this layer of my stack is now demystified :). |
I understand the motivation for not parsing query strings in V4 (i.e. #4410 and #4527). I understand I can parse the query string myself.
Since the query is part of a component's props, components can render based on the query. But since React Router does not react to changes in the query string, a change in the location's query does not cause it update.
What you get is a strange sort of half-coupling to the query state. This is particularly strange given that
<Link to />
can accept a location object, which might specify a query. Navigating to such a link, however, will not do anything if only the query string changed.The only solution I've come up with is to duplicate the query state on the component. The component is initialized with state from the query string, and then changes to the query string must also update the component state.
Am I missing a better way to handle this issue?
The text was updated successfully, but these errors were encountered: