简体   繁体   English

道具类型失败:提供给“输入”的值“搜索”无效的道具“类型”

[英]Failed prop type: Invalid prop `type` of value `search` supplied to `Input`

Getting failed prop type due to type="search" on input. 由于输入的类型为“搜索”,导致道具类型失败。 Says: "Failed prop type: Invalid prop type of value search supplied to Input , expected one of ["text","number","password","date","date-range","email","tel"]" 说:“失败的prop类型:为Input提供的值search无效的prop type ,预期为[“ text”,“ number”,“ password”,“ date”,“ date-range”,“ email”,“ tel”之一]”

 <Input
   type="search"
   onChange={this.onSearchChange}
   iconSize={IconSize.xs}
   color="primary"
/>

The input with type="search" works as intended, but it keeps giving me console errors. type =“ search”的输入可按预期工作,但始终显示控制台错误。 Anyone knows why? 有人知道为什么吗? And how to fix it? 以及如何解决?

The <Input /> is a custom component. <Input />是一个自定义组件。 From the comment, you said it's your own component. 从评论中,您说这是您自己的组件。 Check your prop validation as currently it only allows ["text","number","password","date","date-range","email","tel"] . 检查您的道具验证,因为当前它仅允许["text","number","password","date","date-range","email","tel"]

You can add "search" in the validation. 您可以在验证中添加"search"

If going through the error message. 如果通过错误消息。 "Failed prop type: Invalid prop type of value search supplied to Input, expected one of ["text","number","password","date","date-range","email","tel"] “失败的道具类型:为输入提供的值搜索的无效道具类型,预期为[“ text”,“ number”,“ password”,“ date”,“ date-range”,“ email”,“ tel”]之一

As in your code you have passed value "search" to type property of Input Component. 就像在您的代码中一样,您已经将值“ search”传递给Input Component的type属性。 Basically type doesn't recognise value "search" as it expect value to be "text", "number", "password", "date", "date-range", "email" or "tel". 基本上,类型不能识别值“搜索”,因为它期望值是“文本”,“数字”,“密码”,“日期”,“日期范围”,“电子邮件”或“电话”。

Your Input component will be working fine cause of your some logic written in onSearchChange method. 由于您使用onSearchChange方法编写了一些逻辑,因此您的Input组件可以正常工作。

To fix this error set the value of type which are specified in ["text","number","password","date","date-range","email","tel"]. 要解决此错误,请设置在[“ text”,“ number”,“ password”,“ date”,“ date-range”,“ email”,“ tel”]中指定的类型的值。

For ex. 对于前。 if you're using only text for searching set it to "text", for number set it to "number" and so on. 如果您仅使用文本进行搜索,请将其设置为“文本”,将数字设置为“数字”,依此类推。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 失败的道具类型:提供给“TextInput”的“对象”类型的道具“值”无效 - Failed prop type: Invalid prop 'value' of type 'object' supplied to 'TextInput' 失败的道具类型:提供给“重定向”的无效道具“到” - Failed prop type: Invalid prop `to` supplied to `Redirect` 警告:道具类型失败:提供给 `ForwardRef(Slider)` 的道具 `value` 无效 - Warning: Failed prop type: Invalid prop `value` supplied to `ForwardRef(Slider)` 提供的道具类型无效 - Invalid prop type supplied 反应警告:失败的道具类型:提供的“对象”类型的无效道具 - React Warning: Failed prop type: Invalid prop of type `Object` supplied 失败的道具类型:提供给“RCTView”的“对象”类型的无效道具“不透明度” - Failed prop type: Invalid prop `opacity` of type `object` supplied to `RCTView` 失败的道具类型:提供给`GlobalState`的`array`类型的无效道具`children` - Failed prop type: Invalid prop `children` of type `array` supplied to `GlobalState` 警告:失败的道具类型:提供给“图像”的无效道具&#39;源&#39; - Warning: Failed prop type: Invalid prop 'source' supplied to 'Image' 失败的道具类型:提供给`TypeaheadContainer(WrappedTypeahead)的无效道具`defaultSelected` - Failed prop type: Invalid prop `defaultSelected` supplied to `TypeaheadContainer(WrappedTypeahead)` 警告:道具类型失败:提供给“TextInput”的“number”类型的道具“value”无效,应为“string” - Warning: Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput`, expected `string`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM