Topic: MDB React not rendering content

mrrharris priority asked 9 months ago

I am expecting to see the content in the page but not seeing any content and not getting any errors. I am using react-router v6.

import React from 'react'; import { Routes, Route, Outlet, Link } from "react-router-dom"; import { MDBContainer, MDBNavbar, MDBNavbarBrand, MDBNavbarToggler, MDBIcon, MDBNavbarNav, MDBNavbarItem, MDBNavbarLink, MDBBtn, MDBDropdown, MDBDropdownToggle, MDBDropdownMenu, MDBDropdownItem, MDBDropdownLink, MDBCollapse } from 'mdb-react-ui-kit'; /*function App() { return (' style={{ width: 250, height: 90 }} /> Thank you for using our product. We're glad you're with us. MDB Team' target='_blank' role='button' > Start MDB tutorial ); }

export default App;*/ export default function App() { return (

Basic Example

    This example demonstrates some of the core features of React Router
    including nested <code>&lt;Route&gt;</code>s,{" "}
    <code>&lt;Outlet&gt;</code>s, <code>&lt;Link&gt;</code>s, and using a
    "*" route (aka "splat route") to render a "not found" page when someone
    visits an unrecognized URL.

  {/* Routes nest inside one another. Nested route paths build upon
        parent route paths, and nested route elements render inside
        parent route elements. See the note about <Outlet> below. */}
    <Route path="/" element={<Layout />}>
      <Route index element={<Home />} />
      <Route path="about" element={<About />} />
      <Route path="dashboard" element={<Dashboard />} />

      {/* Using path="*"" means "match anything", so this route
            acts like a catch-all for URLs that we don't have explicit
            routes for. */}
      <Route path="*" element={<NoMatch />} />

); }

function Layout() { return (

{/* A "layout route" is a good place to put markup you want to // share across all the pages on your site, like navigation. */}

  <MDBNavbar expand='lg' light bgColor='light'>
  <MDBContainer fluid>
    <MDBNavbarBrand href='#'>Brand</MDBNavbarBrand>

      aria-label='Toggle navigation'
      onClick={() => setShowBasic(!showBasic)}
      <MDBIcon icon='bars' fas />

    <MDBCollapse navbar show={showBasic}>
      <MDBNavbarNav className='mr-auto mb-2 mb-lg-0'>
          <MDBNavbarLink active aria-current='page' href='#'>
          <MDBNavbarLink href='#'>Link</MDBNavbarLink>

            <MDBDropdownToggle tag='a' className='nav-link'>
                <MDBDropdownLink>Another action</MDBDropdownLink>
                <MDBDropdownLink>Something else here</MDBDropdownLink>

          <MDBNavbarLink disabled href='#' tabIndex={-1} aria-disabled='true'>

      <form className='d-flex input-group w-auto'>
        <input type='search' className='form-control' placeholder='Type query' aria-label='Search' />
        <MDBBtn color='primary'>Search</MDBBtn>

  {/* An <Outlet> renders whatever child route is currently active,
     // so you can think about this <Outlet> as a placeholder for
     // the child routes we defined above. */}
  <Outlet />

); }

function Home() { return ( col="4" col="4" col="4" sm="4" sm="4" sm="4" md="4" md="4" md="4" lg="4" lg="4" lg="4" xl="4" xl="4" xl="4" ); }

function About() { return (


); }

function Dashboard() { return (


); }

function NoMatch() { return (

Nothing to see here!

Go to the home page

); }

mrrharris priority answered 9 months ago

Hi! The error that I am getting is BrowserRouter is not defined.

Krzysztof Wilk staff commented 9 months ago


Could you make a simple GitHub repository with your code? According to the example above you are returning nothing from the component, the code is not formatted and I see you have even more components, so it is hard to say something without it :(

mrrharris priority answered 9 months ago

Hi Krzysztof, Thanks! I have made all of the suggested fixes and my code ran but now after adding the routes the page renders but is blank. No errors. I am new to React so forgive me. I initially saw the header/nav but made a few changes and now I cannot see anything.

Here is App.jsx:

import * as React from 'react'; import Navigation from "./components/navigation"; import Footer from "./components/footer"; import './App.css';

export default function App() { return (




/* eslint-disable */ import * as React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router, Routes, Route, Outlet, Link, } from "react-router-dom"; import App from './App'; import Navigation from "./components/navigation"; import Footer from "./components/footer"; import About from "./components/about"; import Contact from "./components/contact"; import Fade from "./components/fade"; import Wine from "./components/wine"; import Wsgr from './components/wsgr'; import Home from './components/home'; import 'mdb-react-ui-kit/dist/css/mdb.min.css'; import './index.css'; import reportWebVitals from './reportWebVitals';

ReactDOM.render( , }> } /> } /> } /> } /> } /> } /> , document.getElementById("root") ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: reportWebVitals();

Please advise.

Krzysztof Wilk staff answered 9 months ago


There's no problem with our package. The problem is with the example you got. Your routes aren't wrapped with the BrowserRouter component. I assume you got your code from here: As you can see in the main.tsx the whole App is wrapped in BrowserRouter. So you can try wrapping routes as it is in code example or just do it like this:

      <Route path="/" element={<Layout />}>
        <Route index element={<Home />} />
        <Route path="about" element={<About />} />
        <Route path="dashboard" element={<Dashboard />} />

        <Route path="*" element={<NoMatch />} />

and import this router from the package:

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

Everything should work fine now :)

Keep coding!

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Priority
  • Premium support: Yes
  • Technology: MDB React
  • MDB Version: MDB5 1.5.0
  • Device: MacBook Pro
  • Browser: Chrome
  • OS: 12.2.1 Monterey
  • Provided sample code: No
  • Provided link: No