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

Query parameters: updating just the query string #149

Closed
rauschma opened this issue Nov 20, 2015 · 3 comments
Closed

Query parameters: updating just the query string #149

rauschma opened this issue Nov 20, 2015 · 3 comments

Comments

@rauschma
Copy link

If one keeps most of one’s state in the query string (vs. the path), one usually wants to update just the query string, without touching the path. This is how I did it – does that look OK?

// In my custom onClick handler:
this.context.history.pushState({}, document.location.pathname, { someKey: someValue });

// Via a <Link>
<Link to={document.location.pathname} query={{selected: ''}}>Clear selected</Link>

Suggestion – mention here: https://github.com/rackt/history/blob/master/docs/QuerySupport.md

@taion
Copy link
Contributor

taion commented Nov 20, 2015

That's more of a React Router question. You'd really want to use context.location over document.location or window.location.

#141 will provide a better API, eventually.

@rauschma
Copy link
Author

It is indeed. My bad, sorry!

@rauschma
Copy link
Author

Thanks for the tip, wasn’t aware of PropTypes.location!

@taion taion closed this as completed Nov 20, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
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

2 participants