skip to Main Content

i have Routes in the main app and also a Routes in a microfrontend, but it’s not rendering the component of the microfrontend routes.
The website worked fine until i upgraded from v5 to v6 and update the code according to the documentation.

I added Outlet, but still not working, afcourse I have Router.
I only changed the render to element and switch to Routes, and things like those.

2

Answers


  1. are you getting blank screen? while you are upgrading v5 to v6?
    also add screen-shot of routing page

    Login or Signup to reply.
  2. Just run this command

    npm i -D react-router-dom@latest
    

    and follow this structure

    import ReactDOM from "react-dom/client";
    import { BrowserRouter, Routes, Route } from "react-router-dom";
    import Layout from "./pages/Layout";
    import Home from "./pages/Home";
    import Blogs from "./pages/Blogs";
    import Contact from "./pages/Contact";
    import NoPage from "./pages/NoPage";
    
    export default function App() {
      return (
        <BrowserRouter>
          <Routes>
            <Route path="/" element={<Layout />}>
              <Route index element={<Home />} />
              <Route path="blogs" element={<Blogs />} />
              <Route path="contact" element={<Contact />} />
              <Route path="*" element={<NoPage />} />
            </Route>
          </Routes>
        </BrowserRouter>
      );
    }
    
    const root = ReactDOM.createRoot(document.getElementById('root'));
    root.render(<App />);
    

    if you have any doubt simply ask .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search