I am using react-router with react js and i following their documentation but facing this error
while compiling it shows the error,
TypeError: _this.
I encountered this problem when trying to instantiate my own Router rather than using one of the built-in ones, to deal with an issue of having access to the history:
history.js
import { createHashHistory as createHistory } from 'history'
export default createHistory()
root.jsx
import { Router, Route } from 'react-router-dom'
import history from './history'
...
In my case, the trouble was that I had a version of the history package locked at v2.1.2, while react-router was depending on a v4.x version of history in its own dependencies. So the built-in routers instantiated fine using the newer history, but when I tried to do it myself I was pulling in the older history and getting an incompatible object.