gpt4 book ai didi

react-native - 失败的 Prop 类型无效的 Prop 'value'

转载 作者:行者123 更新时间:2023-12-01 22:18:13 25 4
gpt4 key购买 nike

我在 react-native 中引入了一个用于搜索的 Texinput。以下是代码:

      constructor(props){
super(props);
this.state = {
value : "",
items: [],
}

this.handleHeaderSearch = this.handleHeaderSearch.bind(this);
this.handleSearchBtn = this.handleSearchBtn.bind(this);
}
handleSearchBtn(){

}
handleHeaderSearch(){
if(!this.state.value) return;

}

和:

<TextInput
value={this.props.value}
onChange = {this.props.onChange}
placeholder={"جستجو"}
blurOnSubmit={false}
style={{flex:0.9}}
returnKeyType="done"
/>

每当我在输入文本后运行 Android 时,我都会看到这个警告:

"Warning Failed prop type invalid prop 'value' of type 'object' supplied to TextInput, expected 'string'"

最佳答案

您将值存储在 this.state.value 中(或者至少这看起来是您的意图)但您正在传递 this.props.value到您的 TextInput。

如果您确实打算将 this.props.value 传递给 TextInput,这将有助于了解传递给该组件的内容(向上一级) .

关于react-native - 失败的 Prop 类型无效的 Prop 'value',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42377667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com