React-router: Query has been removed after first click on Link

Created on 26 Mar 2017  路  2Comments  路  Source: ReactTraining/react-router

Version

4.0.0

Steps to reproduce

1) create a Link component like that

<Link to={{ pathname: '/homepage', query: {...oldQuery, image: 11} }}>
    Image capture
</Link>

2) Click the first time on this Link
3) Then check the HREF atribute of DOM element

Expected Behavior

After the first click DOM element should be <a href='/homepage?album=1&image=11'>

Actual Behavior

But actually it is <a href='/homepage?album=1&image=11'>

Most helpful comment

The query property of location objects is no longer supported. It would take me a while to explain all the details, but basically it boils down to there being query objects are not standardized and React Router/history not actually have an internal use for query objects. Instead, you should pick your own query package to parse and stringify location.search.

I wrote qhistory for people who really want query support. It works basically the same way that useQueries did with history v2/3.

All 2 comments

The query property of location objects is no longer supported. It would take me a while to explain all the details, but basically it boils down to there being query objects are not standardized and React Router/history not actually have an internal use for query objects. Instead, you should pick your own query package to parse and stringify location.search.

I wrote qhistory for people who really want query support. It works basically the same way that useQueries did with history v2/3.

Thank u for this clarifications!
so, i'll consider your library

Was this page helpful?
0 / 5 - 0 ratings