hookrouter icon indicating copy to clipboard operation
hookrouter copied to clipboard

navigate() does not keep queryparameter even with fourth argument set to false

Open alex-frx opened this issue 3 years ago • 3 comments

navigate("/authentication?test=true",false,{a:false},false); only ?a=false will be appended

alex-frx avatar Apr 18 '21 01:04 alex-frx

Hey, @alex-frx I am navigating using navigate api. The URL is changing but the page is not heading to a new page. Why is it happening?

khushal87 avatar Apr 24 '21 10:04 khushal87

@khushal87 im not associated with the project but maybe i can help. open a new issues that is related to your question and include your component that redirects and your routes

alex-frx avatar Apr 24 '21 12:04 alex-frx

This issue is also relevant for the use of the A element in this package.

I suspect that the call to navigate in https://github.com/Paratron/hookrouter/blob/e0ceb4a6ed495a59754351aff6ad54ce5c124512/src/Link.js#L24 should be changed into something like this:

    let params = {}
    if(e.currentTarget.href.indexOf("?")>-1) {
        params = Object.fromEntries(new URLSearchParams(e.currentTarget.href.split( "?")[1]))
    }
    navigate(e.currentTarget.href, false, params, false)`

Ueland avatar Jul 23 '21 12:07 Ueland