react-router render menu when path does not match

后端 未结 6 1744
一向
一向 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 11:44

    Taken Regex from Arman's answer.

    const notInLogin = /^(?!.*(\/login)).*$/
    
    export default () => (
      
        <>
          
          
            
            
            
            
          
        
      
    )
    

    If you get PropsType error: https://stackoverflow.com/a/50439120/1099314

提交回复
热议问题