from ‘react-router-dom’Īfter these changes, we don’t get the above error anymore. But both props wok in a special way when applied to NavLink.ĬlassName prop in NavLink does not just take the class name, instead, it takes a function which we can pass inside className prop, and this function will give us some information about the link and the current state of navigation. Doing that is very simple, because still we can use the className prop or the style prop to apply the dynamic CSS style. Instead, if we want to apply specific class once the link became active, we have to find out manually, whether this link is active or not. With Router v.6, activeClassName prop is removed. With Router v.5 we could use this prop to apply some CSS class automatically to the link once the link became active. Navlink is moreover same as v.5, however, what did change in v.6 is the activeClassName prop. We still have the Link component in v.6, which generally works as you learned in v.5, there is no change. In the previous article, we saw the initial and important changes we need to consider when migrating from react-router-dom v.5 to v.6.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |