How to restrict access to routes in react-router?

后端 未结 7 1541
暗喜
暗喜 2020-12-07 08:49

Does anyone know how to restrict access to particular routes in react-router? I want to check if the user is logged in before allowing access to a particular route. I though

7条回答
  •  庸人自扰
    2020-12-07 09:13

    You can use HOC and auth is a variable you can change value true or false means(authorization)

    
     (auth ?  () : ())}/>
    

提交回复
热议问题