リアクティブネイティブ検索バーから検索バーを追加してリストをフィルタリングしようとしましたが、エラーをスローします。代理人は定義されていません。私はここから何をすべきかわからない、申し訳ありませんが、RNで非常に新しいです!データは流星アプリからのものです。リザルトネイティブを使用した検索バー
class Flat_List extends Component{
constructor(props){
super(props);
this._handleResults = this._handleResults.bind(this);
this.state = { dataSource : { deputies } };
}
_handleResults(results){
this.setState({dataSource: this.props.deputies(results)})
}
render(){
const {deputies}= this.props; // the list is here
return(
<View>
<SearchBar
ref={(ref) => this.searchBar = ref}
data={deputies}
handleResults={this._handleResults.bind(this)}
showOnLoad
allDataOnEmptySearch
hideBack
autoCorrect= {false}
/>
<List>
<FlatList
data={this.props.deputies}
keyExtractor={(item)=> item._id}
renderItem={({item})=>(
<DeputyDetail deputy={item.depute} navigation={this.props.navigation} />)} />
</List>
</View>
);
}
export default createContainer(params => {
Meteor.subscribe('deputies');
return { deputies: Meteor.collection('deputies').find() };
}, Flat_List);
あなたが投稿できます'Flat_List'の親のコード/その呼び出しサイト? 'props'は定義されていないので正確に渡していない可能性がありますが、親コンポーネントを見ることができればデバッグが簡単です。 –
は実はこれが親で、データが 輸出デフォルトcreateContainerから来ている(のparams => { Meteor.subscribe( '議員'); リターン{ 議員:Meteor.collection( '議員')(見つける)、 。 }; }、Flat_List); – Sonia
さて、 'render.do'が呼ばれるまでに' this.props.deputies'が到着していることを確認することから始めたいと思います。そうでない場合は、定義されません。それがあなたの最初の一歩です。データが到着したというチェックを、3項演算子 'this.props.deputies? this.props.deputies:["Data not arrived"] ' - それが到着しなければ、' render is called'時には未定義です。コードには他にもいくつか問題がありますが、そこから始めてください! –