Home > OS >  React-Router Blank Page
React-Router Blank Page

Time:02-18

I'm still learning to using react-router. I just wondering why my page is blank.

App.js :

import {
BrowserRouter as Router,
Routes,
Route
} from "react-router-dom";

export default function App() {
return (
  <Router>
    <Routes>
      <Route exact path="/" element={<MainPage/>}/>
    </Routes>
  </Router>
);
}

CodePudding user response:

React Router v6 doesn't support exact anymore because all paths are match exactly by default

<Route path="/" element={<MainPage/>}/>

CodePudding user response:

You have to import MainPage from its path.

import MainPage from "layouts/pages/index";

Like this.

  • Related