U
U
Undefined User2021-11-07 23:49:19
JavaScript
Undefined User, 2021-11-07 23:49:19

(React Router)TypeError: Cannot read properties of undefined (reading 'location') how to fix?

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { Route, BrowserRouter as Router } from 'react-router-dom';
import createHistory from 'history/createBrowserHistory'; 
import AboutPage from './pages/aboutPage'

const history = createHistory();  

ReactDOM.render(
  <React.StrictMode>
    <Router history={ history }>
    <Route exact path='/' element={ App }/>
    <Route path='/about' element={ AboutPage }/>
    </Router>
  </React.StrictMode>,
  document.getElementById('root')
);

I've been struggling with this error for a long time now. Either I'm dboeb, or the skis don't go, but googling didn't lead to anything. 61883b9434ee3091973879.png

Router.js file code: https://jsfiddle.net/mustmusk/kcpmxzaw/
React v17.0.2, React-router v5.2.1, React-router-dom v6.0.1

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question