React App goes blank after importing React-Router-Dom

Issue

The Route component API changed in react-router-dom@6. All routed content is now rendered on a single element prop as a ReactNode, a.k.a. JSX, not a reference to a React component.

Solution

Render the routed components as JSX, i.e. <Home /> instead of Home.

import { BrowserRouter, Routes, Route } from "react-router-dom";
import 'bootstrap/dist/css/bootstrap.min.css';
import Pending from './Pages/Home';
import Home from './Pages/Pending';

export default function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/Pending" element={<Pending />} /> 
      </Routes>
    </BrowserRouter>
  );
}

Leave a Comment