Topic: MDBDropdown 4.2.0 refactors are probelmatic

clickstudioltd priority asked 3 months ago

In the new release, there are multiple issues with drop down that I've faced.

First, if the MDBDropdownItem does not have the link property, it's not shown in the drop down list and if I add the link property, then React nags about DOM invalidity by having nested a tags which is problematic because I have to use the router provided by InertiaJS in order to navigate around.


<MDBSideNavItem link>
    <Link href={route('dashboard.users.index')}>
        <MDBIcon icon="users" className="me-3" fas fixed /> Users

This will result in something like this which is no good:

        <a href="dashboard/users/index">Users</a>

Second, I can't perform any logic inside the MDBDropdownMenu component because as soon as it's opened, I get this error: Uncaught TypeError: e is null


    {showProfile && <MDBDropdownItem link href="dashboard/profile">Profile</MDBDropdownItem>}

I have tested this with just a simple console.log() inside the component too, and it still gives me the same error so I don't think this is related to my own code.

clickstudioltd priority answered 1 month ago

For anyone in the future that stumbles upon this issue this is the fix. In this version of MDBReact, inside of the MDBDropdownMenu component should there be an expression that would result in null or false, you will be greeted with the e is null error.


    {someValue === true && (
        <MDBDropdownItem link>
            Test menu

The issue is that the result of this expression might be false therefore and empty statement will be returned and with the new refactors, this will yield in an error.

To fix this issue, simply return a Fragment element if the result of the expression is false:

    {someValue === true ? (
        <MDBDropdownItem link>
            Test menu
    ) : (

Stanisław Jakubowski staff answered 3 months ago


To fix the first issue try doing something like this:

<MDBDropdownItem link childTag='span'>
    <Link to='dashboard/users/index'>Users</Link>

The output would look like this which is correct:

     <a href='dashboard/users/index'>Users</a>

I've tried recreating your second issue but I don't see any errors. In case it still exists please create a snippet ( so we can see exacly where the problem is.

clickstudioltd priority commented 3 months ago

For the first problem, the solution is good but not enough. If I do this, then my link won't take over all the space of the drop down row. Even if I add a d-block class to my link, there is still a padding for dropdown-item class which prevents my link to be stretched to take over all the row. With this refactoring, the only way for me is to override the dropdown-item class from CSS to get the desired result and that's not what I prefer.

For the second problem, your snippet maker only supports up to MDBReact version 4.0.0. Needless to say that this problem occurs only in 4.2.0.

Stanisław Jakubowski staff commented 3 months ago


Unfortunately the first solution is the only one available for the moment. We will take a closer look at using our Dropdown with components from external libraries. For the second problem, please provide a github repository where this problem exists.

Keep coding!

clickstudioltd priority commented 1 month ago

I posted the answer on how to fix this problem. If it helps you to further improve this component so others wouldn't be baffled like me, please take a look at it.

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 4.2.0
  • Device: PC
  • Browser: Mozilla Firefox
  • OS: Windows 10
  • Provided sample code: Yes
  • Provided link: No