react-router render menu when path does not match

后端 未结 6 1715
一向
一向 2020-12-20 11:36

I\'m using react-router and I want to render a menu component when the user is not in the root and not in the /login path. This is what I have so far

6条回答
  •  隐瞒了意图╮
    2020-12-20 12:01

    Regex in the route path didn't work for me. What worked for me was this. Just add the other condition.

      {
         return location.pathname.indexOf('/login') === -1 ? TopMenuComponent : null 
      }} />
    

提交回复
热议问题