【发布时间】:2018-11-14 12:28:39
【问题描述】:
我刚刚将我的 React 应用程序更新到 16.6.0 并将 react-scripts 更新到 2.0.3 以开始使用惰性,并且在按照官方文档上的示例进行操作时出现此错误:
失败的道具类型:提供给Route的object类型的无效道具component,应为function
不管它,一切似乎都在工作,除了控制台中的这个错误。
这是我的一些代码:
// imports here
...
const Decks = lazy(() => import('./pages/Decks'));
...
class App extends Component {
...
render() {
return (
<ConnectedRouter history={history}>
<div>
<MenuAppBar />
<div style={{paddingTop: '4rem'}}>
<Suspense fallback={<LazyLoading />}>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/decks" component={Decks} />
...
</Switch>
</Suspense>
</div>
<Footer />
</div>
</ConnectedRouter>
);
}
... }
我在这里做错了什么?
【问题讨论】:
标签: javascript reactjs react-router