Answer the question
In order to leave comments, you need to log in
How to set browserHistory in React-router?
I'm trying to set up React-router with api v2, I had problems with switching links, before that everything worked, but in the console it gave a warning. The links themselves change, but the elements do not (that is, nothing happens)
How to set it up correctly?
Router settings
import { Home } from './Home';
import { Router, Route, IndexRoute, PropTypes, hashHistory, Link, browserHistory } from 'react-router';
export class App extends Component {
constructor(props, context) {
super(props);
context.router
}
render() {
return (
<Router history={hashHistory}>
<Route path="/" component={UserHome}>
<IndexRoute component={UserActivities}/>
<Route path="NewPatient" component={NewPatient} />
<Route path="PatientSer" component={PatientSer}/>
...
</Route>
</Router>
export class Home extends Component {
constructor(...args) {
super(...args);
this.state = { };
changeUsers(){
this.browserHistory.push("Users");
}
render() {
return (
<MenuItem onClick={()=>this.changeUsers()}>Manage Users</MenuItem>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question