[Vuejs]-React-router-dom v6.4.2 NavLink is not working in dropdown

-2👍

in your Routes mapping, update the code to :

{submenu.length > 0 ? (
  <React.Fragment>
    {submenu.map((items, index) => (
      <Route exact key={index} path={items.path} element={items.element} />
    ))}
  </React.Fragment>
) : (
  <Route exact path={path} element={element} />
)}

please check if the activeDropdown state variable is correctly set and matches the index you’re comparing it with in the condition {activeDropdown === index}. Verify that index and activeDropdown have the correct values.

Leave a comment