React-router: Support for parsing location.search

Created on 31 Jan 2017  路  2Comments  路  Source: ReactTraining/react-router

First off - really loving v4 and the flexibility it provides! Thanks for your hard work!

In the alpha, you could access the parsed search string off of the location object, so that /route?doTheThing=absolutely could be accessed in a route via location.query.doTheThing. Do y'all ever plan to support that in v4, or should I be using some other lib to parse location.search? I've got it working with query-string for now (first parser I found) which works just fine, but it does seem nice to have access to that parsed string via the RR API instead of needing to pull in another dependency. Then again, given the more simplified API in general, I could also see an argument for leaving it up to consumers to choose how they want to handle that string themselves. Or maybe it'd go in as a part of the history API?

Mostly just trying to see if y'all have already made a decision one way or the other. If it's something you'd consider adding, I'd be up for taking a stab at it.

Thanks!

All 2 comments

@kgoggin you may be interested in react-router-parsed, a microlibrary I made that wraps <Route> with parsing logic you specify and injects parsed params and query into the route component.

I have found everything goes more smoothly if I pass in the parsed values to my Route components as props, rather than parsing match.params.whatever or location.search within my Route components.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolashery picture nicolashery  路  3Comments

ryansobol picture ryansobol  路  3Comments

yormi picture yormi  路  3Comments

misterwilliam picture misterwilliam  路  3Comments

alexyaseen picture alexyaseen  路  3Comments