React Router v4 setting activeClass on parent

前端 未结 4 1075
猫巷女王i
猫巷女王i 2021-01-17 16:13

Not too familiar with react router, but I need the functionality of the NavLink to set the active class on the parent li element, and not the a ele

4条回答
  •  春和景丽
    2021-01-17 16:37

    I found that by using CSS you can make the active link expand to fill up it's parent

  • element by setting display:block; in the active class.

    For example if our link was:

  • Overview
  • then our CSS would be:

    &__sideLinkSelected
    {
      background-color: blue;
      display:block;
    }
    

提交回复
热议问题