1
上のデータを取得:私はあなたが特定のアイテムを検索できるページを持ってしようとしていますはネイティブリアクト - リストビューのエラーは私がやろうとしていますどのような同じ画面
、これはその後、APIにリクエストを送信しますこの検索に基づいて一連の値が返されます。
現在、ユーザーが検索キーワードを入力して[OK]をクリックするまで表示されないリストビューを使用しています。ユーザーが検索をクリックすると、リストビューはその返信で更新されます。何が起こっている
:ユーザーが検索をクリックすると
、私は次のエラーを取得する:ここで
Undefined is not an object (evaluating dataSource.rowIdentities)
コードは、これまでのところです:
class Search extends Component {
constructor(props) {
super(props);
this.state = {
term: '',
showResults: false,
isSearch: false,
SearchResults: ''
}
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
SearchResults: this.ds.cloneWithRows(["Row 1", "Row 2"]),
};
}
onSearchButtonPress() {
this.setState({isSearch: true});
}
_renderCategoryIcon() {
}
_renderSearchResults(item) {
return (
<Text>Hello world</Text>
)
}
render() {
if(this.state.isSearch)
{
return (
<ViewContainer>
<StatusBarBackground style={{backgroundColor: "#009fe3"}} navigator={this.props.navigator} />
<SearchBar
placeholder='Search'
onChangeText={(text)=> this.setState({term: text})}
onSearchButtonPress={this.onSearchButtonPress.bind(this)}
/>
<ListView
style={styles.containerView}
enableEmptySections={true}
horizontal={false}
initialListSize={10}
dataSource={this.state.SeachResults}
automaticallyAdjustContentInsets={false}
renderRow={(item) => { return this._renderSearchResults(item) }} />
</ViewContainer>
);
}else{
return (
<ViewContainer>
<StatusBarBackground style={{backgroundColor: "#009fe3"}} navigator={this.props.navigator} />
<SearchBar
placeholder='Search'
onChangeText={(text)=> this.setState({term: text})}
onSearchButtonPress={this.onSearchButtonPress.bind(this)}
/>
</ViewContainer>
)
}
}
}
const styles = StyleSheet.create({
title: {
fontSize:30,
},
});
いや..は同じエラーを取得:( – Phorce
あなたはJSXでスペルミスがあります: 'DataSourceが= {this.state.SeachResultsを}' ..あなたの不足している "R" .. dataSource = {this.state.SearchResults} ' これはそれですか? – David
fええ!7枚目の質問私はこのシートを見ています、これは動作する答えです!!よくやった!もちろん新しいエラー:D) – csomakk