React-router TypeError: _this.props.history is undefined

This is because things changed in React Router starting with 4.0.0. You should now use BrowserRouter from react-router-dom package when you were using browserHistory. So your code will looks like:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import { BrowserRouter, Route } from 'react-router-dom';

ReactDOM.render(
    <BrowserRouter>
        <Route path="https://stackoverflow.com/" component={ App }/>
    </BrowserRouter>, document.getElementById('root')
);

Of course, you’ll need to install react-router-dom first.

Also note that if you’re using more than one Route element, you’ll have to use a Switch as explained in this answer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)