reactjs - 失败的道具类型:提供给“路线”的“对象”类型的无效道具“组件”
问题描述
我尝试了几种解决方案,但没有任何效果,
我只循环我的路线,但我仍然有这个错误
警告:道具类型失败:提供给component
的道具类型无效,应为。在 Route (at Auth.js:14) in Auth (由 ConnectFunction 创建) 在 ConnectFunction (at App.js:31) 在 Route (at App.js:31) 在 Switch (at App.js:29) 在 Router (由 BrowserRouter 创建)在 BrowserRouter(在 App.js:27)在 Provider(在 App.js:26)在 App(在 src/index.js:5)object
Route
function
// Auth.js
...
getRoutes = routes => {
return routes.map((rte, key) => {
if (rte.layout === "/auth") {
return (
<Route
path={rte.layout + rte.path}
component={rte.component}
key={key}
/>
);
} else {
return null;
}
});
};
...
// App.js
...
<Provider store={store}>
<Router>
<Fragment>
<Switch>
<PrivateRoute path="/admin" render={props => <AdminLayout {...props} />} />
<Route path="/auth" render={props => <AuthLayout {...props} />} />
<Redirect from="/" to="/auth/login" />
</Switch>
</Fragment>
</Router>
</Provider>
...