react-router render menu when path does not match

后端 未结 6 1757
一向
一向 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:08

    If you don't wish to use Regular Expressions directly, you can place your login Route in a Switch with the top menu component Route. It will only run the first matching Route and routes without a path attribute match anything.

    ( )} />

    For your example, you would need to reorder your divs.

提交回复
热议问题