azouaoui-med / react-pro-sidebar

React Pro Sidebar provides a set of components for creating high level and customizable side navigation
https://azouaoui-med.github.io/react-pro-sidebar/
MIT License
1.69k stars 414 forks source link

How to active links dynamically without adding 'active' props menu or with 'active' props applied but detected automatically #178

Closed emmannweb closed 8 months ago

emmannweb commented 1 year ago

Describe the bug

      backgroundColor: 'red',
       color: 'green',
},

And for the Menu: <MenuItem active component={<Link to="/seller/dashboard" />} icon={<DashboardIcon />}> Dashboard </MenuItem> <MenuItem component={<Link to="/seller/orders" />} icon={<ReceiptIcon />}> Orders</MenuItem>

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

azouaoui-med commented 1 year ago

if you are using react router, the active class will be added automatically, if not you need to use the active prop to add the relevant class to use it for styling

emmannweb commented 1 year ago

Well, thanks for answering! I remember, it worked on some previous version of React Router (6.6.2), With the version that i'm using it's not working, When i check in the source code in the browser, i don't see any active class added, i don't know what's going on. I have added the active class to test it.

vaynevayne commented 1 year ago

same issue, i use react-router v6, can see any class added to dom

blombosi commented 11 months ago

For anyone who has the same issue just use NavLink instead of Link from react-router

danieleagle commented 11 months ago

@blombosi, after spending several hours on this, changing from Link to NavLink totally solved it. Thank you so much.

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.