react router v^4.0.0 Uncaught TypeError: Cannot read property ‘location’ of undefined

You’re doing a few things wrong.

  1. First, browserHistory isn’t a thing in V4, so you can remove that.
  2. Second, you’re importing everything from react-router, it should be react-router-dom.
  3. Third, react-router-dom doesn’t export a Router, instead, it exports a BrowserRouter so you need to import { BrowserRouter as Router } from 'react-router-dom.

Looks like you just took your V3 app and expected it to work with v4, which isn’t a great idea.

Leave a Comment