Ad

Using React-router History To Change Path Adds ? Before #

- 1 answer

I'm using react router in my redux web app when i try to update the route using

this.props.history.push('/route')

It adds a ? to the address like so

https://website.com/?#/route

When it should look like this

https://website.com/#/route

This causes my single page application to reload.

Things i tried:

  • upgrading react router to latest (2.0.1, currently using 1.0.3) didn't help
  • we're using hash history, switching to browser history didn't help
Ad

Answer

Is it because you're using <form> with React, and it's submitting a form.

See this answer for a better explanation: https://stackoverflow.com/a/32570827/5498949

Ad
source: stackoverflow.com
Ad