Search code examples
javascriptreactjsreact-hooksreact-router-dom

Query Params get removed from react route when click on button


I am facing an issue in react js, there is the route to the page e.g https://localhost:3000/profile?abc=123, the URL is browsed successfully but the issue is when I click on the button (I call API on click of this button using Axios) in my website then the query params in the URL gets removed automatically like this, https://localhost:3000/profile. I have debugged, and the params are removed when the Axios call is initiated. Any help would be highly appreciated.


Solution

  • I had the same issue. It turned out that I was using <Link to='' />. Changing it to <Button /> fixed the issue.