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

How to do multiple optional params with react-router? #2762

Closed
littlee opened this issue Dec 24, 2015 · 6 comments
Closed

How to do multiple optional params with react-router? #2762

littlee opened this issue Dec 24, 2015 · 6 comments

Comments

@littlee
Copy link

littlee commented Dec 24, 2015

I am working on a search page.
And the page should have some filter condition
and the url look like this in regular way:
?sort=price&type=a&rangeStart=10&rangeEnd=100
how do I make it in react-router way?

I was think about I can do it in this way, because the params is optional,
so the route could be
/search(:/sort)(:/type)(:/rangeStart)(:/rangeEnd)

but how do I know which query is passed in url, and which not?

@taion
Copy link
Contributor

taion commented Dec 24, 2015

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 Dec 24, 2015
@icem
Copy link

icem commented Dec 24, 2015

@littlee have a look at query params examples https://github.com/rackt/react-router/blob/master/examples/query-params/app.js

let { query } = this.props.location
let age = query && query.showAge ? '33' : ''

@littlee
Copy link
Author

littlee commented Dec 24, 2015

thanks

@eldyvoon
Copy link

@icem The link is dead, can you post a working link?

@littlee
Copy link
Author

littlee commented Mar 20, 2017

https://github.com/ReactTraining/react-router/blob/v3/examples/query-params/app.js

@eldyvoon

@loopmode
Copy link

So basically the lesson here is: you don't have to declare query params in a route at all, whatever queryParams exist at runtime will be available via location.query anyways. Right?

@remix-run remix-run deleted a comment from rajmeghpara Jan 14, 2018
@remix-run remix-run deleted a comment from Shayan20 Jul 29, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 27, 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

5 participants