N
N
Ninja Mate2016-04-14 18:30:14
JavaScript
Ninja Mate, 2016-04-14 18:30:14

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>

Switching should occur in Home
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

1 answer(s)
A
Aves, 2016-04-14
@victorzadorozhnyy

<Router history={hashHistory}>replace with browserHistory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question