我正在使用position
,并且在构建Web应用程序时出现错误
unlive
我仅在3个地方使用过Cannot call this method while RecyclerView is computing a layout or scrolling android.support.v7.widget.RecyclerView
,即使在我评论并构建它们时,我仍然遇到相同的错误。在本地主机上使用React-Router 4.3.1
没有错误,只有当我使用Invariant Violation: "You should not use <Redirect> outside a <Router>"
并通过<Redirect />
代理提供它时,它才会出现。
我这样使用serve
express
也这样
nginx
在哪里
<Redirect />
和其他<Switch>
<ProtectedRoute
path="/dashboard"
name="Home"
component={DefaultLayout}
/>
<ProtectedRoute
path="/"
name="Home"
component={DefaultLayout}
/>
<Redirect to="/404" />
</Switch>
这样的
ProtectedRoute
最后一个为
<Route
path={path}
{...rest}
render={props => {
console.log(getCurrentUser());
if (!getCurrentUser()) {
return (
<Redirect
to={{
pathname: "/login",
state: { from: props.location }
}}
/>
);
} else {
return Component ? <Component {...props} /> : render(props);
}
}}
/>
我的使用方式有什么问题。
使用<Redirect />
,我可以毫无问题地服务。