我非常了解我想对组件进行条件渲染的react-router-dom。如果未登录use,则将他重定向到某个第三方URL
例如,下面的代码看起来很整洁,可以正常工作
<Route exact path="/home" render={() => ( isLoggedIn() ? ( <Redirect to="/front"/> ) : ( <Home /> ) )}/>
让我们在上面的示例中说,如果我想重定向to https://www.google.com, 该怎么做?
to
如果我写
<Redirect to="https://www.google.com"> it gives me error.
如何重定向到第三方网站?
您可以将标记用于外部网址,
<a href='https://domain.extension/external-without-params'>external</a>
但您也可以提供这样的组件:
<Route path='/external' component={() => { window.location = 'https://domain.extension/external-without-params'; return null;} }/>