reactjsroutes

I cannot Route the pages in React


I have tried to link some pages in React. I have installed react-route-dom, I tried some solutions online but I still get the same error. Any help will be appreciated.

This is the code in my index.js

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import 'bootstrap/dist/css/bootstrap.min.css';
import { BrowserRouter } from 'react-router-dom';
import { Route, Routes } from 'react-router-dom';



ReactDOM.render(
    <React.StrictMode>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={ <App /> }>
          </Route>
        </Routes>
      </BrowserRouter>
    </React.StrictMode>,
    document.getElementById('root')
  );

And this is the code in my App.js

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import 'bootstrap/dist/css/bootstrap.min.css';
import { BrowserRouter } from 'react-router-dom';
import { Route, Routes } from 'react-router-dom';



ReactDOM.render(
    <React.StrictMode>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={ <App /> }>
          </Route>
        </Routes>
      </BrowserRouter>
    </React.StrictMode>,
    document.getElementById('root')
  );

It just gives me this error

ERROR
react_dom_client__WEBPACK_IMPORTED_MODULE_1__.render is not a function
TypeError: react_dom_client__WEBPACK_IMPORTED_MODULE_1__.render is not a function
    at ./src/index.js (http://localhost:3000/Cordia360/static/js/bundle.js:1758:47)
    at options.factory (http://localhost:3000/Cordia360/static/js/bundle.js:67837:31)
    at __webpack_require__ (http://localhost:3000/Cordia360/static/js/bundle.js:67237:32)
    at http://localhost:3000/Cordia360/static/js/bundle.js:68480:37
    at http://localhost:3000/Cordia360/static/js/bundle.js:68482:12

I am stuck and have no idea what I can do. Please help.


Solution

  • I have set up basic routes, Here is the link: react with react-router-dom.