[英]react router, multiple components warning: Failed prop type: Invalid prop `component` supplied to `Route`
As per https://github.com/ReactTraining/react-router/blob/master/docs/API.md#components-1 , I'm specifying multiple components in my routes, and I'm getting warnings. 根据https://github.com/ReactTraining/react-router/blob/master/docs/API.md#components-1 ,我在路由中指定了多个组件,并且收到警告。 It seems to work fine, but I like to heed warnings.
似乎工作正常,但我喜欢注意警告。
Warning: Failed prop type: Invalid prop `component` supplied to `Route`.
I saw several other questions on this warning and the answer is usually to check spelling. 我在此警告上看到了其他几个问题,答案通常是检查拼写。 I don't think it's a spelling issue.
我认为这不是拼写问题。
<Route path="search" component={Search} />
<Route path="search2" component={{main:Search}} />
The first gets no warning but the second one does (as do routes where I'm actually specifying multiple components). 第一个没有警告,但第二个没有(我实际上指定多个组件的路由也是如此)。
component
!= components
component
!= components
Multiple components are provided via the components
property, not the singular component
: 通过
components
属性提供了多个组件,而不是单个component
:
// # component; singular
<Route path="/" component={App}> # component; singular
// # components; plural
<Route path="groups" components={{main: Groups, sidebar: GroupsSidebar}} />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.