我在 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;
}
Run Code Online (Sandbox Code Playgroud)
和:
<TextInput
value={this.props.value}
onChange = {this.props.onChange}
placeholder={"?????"}
blurOnSubmit={false}
style={{flex:0.9}}
returnKeyType="done"
/>
Run Code Online (Sandbox Code Playgroud)
每当我在输入文本后运行 Android 时,我都会看到以下警告:
“警告失败的道具类型无效道具“值”的类型“对象”提供给 TextInput,预期为“字符串”
您将值存储在this.state.value(或至少看起来是您的意图)中,但您正在传递this.props.value给您的 TextInput。
如果您确实打算传递this.props.value给 TextInput,那么了解传递到该组件中的内容(上一级)会有所帮助。
| 归档时间: |
|
| 查看次数: |
25903 次 |
| 最近记录: |