stkvtflw
stkvtflw

Reputation: 13577

React router: merge query

react-router: ^2.0.0

i have, say, this path currently:

http://localhost:8000/feed?type=topics

What is the right way to add one more property to query? Say, &offset=18.

And how do i properly update only this specific property in query?

Do i have to assemble the entire path, params and existing query from separated pieces from this.props.location?

I've found a lot of recommendations for previous versions, but nothing for current.

Also, is there good documentation for react-router somewhere? The docs in repo are insufficient.

Upvotes: 0

Views: 647

Answers (1)

Tareq Jobayere
Tareq Jobayere

Reputation: 709

Here is the doc for QuerySupport

Just need to update the query object history.push({ pathname: '/the/path', query: { the: 'query' } }); You can use Link too <Link to={{ pathname: '/user/bob', query: { showAge: true } }} activeClassName="active">Bob With Query Params</Link>

Upvotes: 2

Related Questions