梗概

  • 使用<Router>组件的render属性来条件性地渲染 <Profile /> 组件或者重定向到首页。

示例

 <Route
   path="/profile"
   render={() =>
     isAuthenticated ? <Profile /> : <Redirect to="/login" />
   }
 />