I use the following code to change my React Router path:
import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import { Router, Route, browserHistory, IndexRoute } from 'react-router'
var currentRouteName = this.props.location.pathname;
const path = currentRouteName + '/yes';
browserHistory.push(path);
The router looks like this:
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/review/request/:id">
<IndexRoute component={QuestionBox}/>
<Route path="yes" component={PositiveBox}/>
<Route path="no" component={NegativeBox}/>
<Route path="thank-you" component={ThankYouComponent}/>
</Route>
</Router>
), document.getElementById('parent-div'))
When I change the path with the above code I get a hashmark # in my URL, i.e. http://localhost:8080/review/request/5066549580791808/yes#
When I click back in the browser the hash will disappear and give me the path: http://localhost:8080/review/request/5066549580791808/yes
But the view won't update, if I hit back again, it will go back to the root path of:
http://localhost:8080/review/request/5066549580791808
And the view will change the IndexRoute again. What I think and what I want to have happen is to only have to hit the back button one time.
Can someone tell me what I am doing wrong? Thanks!