使用`react-router-dom`进行用户身份验证?

时间:2017-08-10 14:30:53

标签: reactjs react-router

嗨我有一个要求,如果用户loggedIn有两个条件,我必须渲染一个组件

1:如果用户loggedin未显示somecomponent //我已实现

2:但即使用户未处于component模式,我也需要渲染一些loggedin

问题陈述:如何在运行时访问正在呈现的组件

我的方法:用网址抓住

if (this.props.match.url == '/someulr'){
  // code for no authntication
}

 but what if a url is like this '/someurl/:id' // where id is variable

应用正则表达式对于此

的任何想法都不是一个好主意

0 个答案:

没有答案