TypeError: Cannot read property ‘location‘ of undefined [How to Solve]

react-router-dom default version problem.
Use hashrouter instead to solve

 

import { HashRouter, Route, Switch, Redirect, Link } from ‘react-router-dom’

<HashRouter>
      <Switch>
          <Route path="app" component={App} />
          <Route path="about" component={About} />
          <Route path="inbox" component={Inbox}>
            <Route path="messages/:id" component={Message} />
          </Route>
        <Redirect from="/" to="/app" exact />
      </Switch>
    </HashRouter>

Similar Posts: