Warning: Failed prop type: Invalid prop value of type number supplied to Textinput, expected string

我也遇到这个问题 借鉴一下别人的

react-native 使用TextInput标签时会遇到这个警告:

Warning: Failed prop type: Invalid prop value of type number supplied to Textinput, expected string in Textinput (at Appointmentnumber is: 112) in Appointmentnumber(created by Context. Consumen)in withnavigation(Appointmentnumber)(created bySceneview

image.png

在道具中你传递的是数值,你必须以字符串的形式传递它,所以这样改进一下代码:

<TextInput
  style={styles.textinput}
  placeholder="站厅预约人数"
  placeholderTextColor = "#cccccc"
  keyboardType = "numeric"
  value={`${this.state.num}`} //这里改进一下就OK
  onChangeText={(num)=> {this.setState({num})}}
/>

原文链接:https://blog.csdn.net/quhongqiang/article/details/88837813

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。