![]() We memoize the MyNavLink component in order to avoid unnecessary re-renders (see this). import >Īnd then I’d use it in a Router like this: Ī few things about the code. ![]() Second, you use NavLink in order to render links that will display as active whenever the URL is matching the current page URL. Although the documentation on the MUI website provides a few examples on how to achieve a similar result with the Link component (from react-router-dom), I still ran into a couple issues and needed to spend a few hours to figure out what was going on.įirst, I was using react-router-dom v6 and MUI v5 for this example, if you’re using different versions of these packages, you may need a different implementation. So, recently I needed to render a React Router NavLink component as a ListItemButton. DecemUsing React Router NavLink with a MUI ListItemButton + TypeScript
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |