简体   繁体   English

反应路由器,多个组件警告:道具类型失败:提供给“路线”的道具“组件”无效

[英]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.

相关问题 警告:失败的道具类型:提供给“路由”的无效道具“组件”-react-router-dom - Warning: Failed prop type: Invalid prop 'component' supplied to 'Route' - react-router-dom 警告:道具类型失败:提供给“路由”的道具“组件”无效:道具不是路由中的有效 React 组件 - Warning: Failed prop type: Invalid prop 'component' supplied to 'Route': the prop is not a valid React component in Route 警告:道具类型失败:提供给“路线”的道具属性无效。 在途中 - Warning: Failed prop type: Invalid prop `component` supplied to `Route`. in Route 警告:道具类型失败:提供给“路线”的道具属性无效。 &警告:[反应路由器]位置“ /”与任何路线均不匹配 - Warning: Failed prop type: Invalid prop `component` supplied to `Route`. & Warning: [react-router] Location “/” did not match any routes 警告:失败的道具类型:提供给“路由”的“对象”类型的无效道具“组件”,预期的“函数”使用 react-router-dom 错误 - Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function` Error using react-router-dom React-Router:失败的prop类型:在route中提供给Route的无效prop`component` - React-Router: Failed prop type: Invalid prop `component` supplied to `Route` in route 警告:道具类型失败:提供给“Route”的“object”类型的无效道具“component”,预期为“function” - Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function` 反应警告:失败的道具类型:提供的“对象”类型的无效道具 - React Warning: Failed prop type: Invalid prop of type `Object` supplied 警告:道具类型失败:提供给“路线”的道具“组件”无效 - Warning: Failed propType: Invalid prop 'component' supplied to 'route' 警告:失败的 propType:提供给 `Route` 的 prop`component` 无效 - Warning: Failed propType: Invalid prop `component` supplied to `Route`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM