반응 네이티브 검색 창에서 검색 창을 추가하여 목록을 필터링하려고합니다. 그러나 이렇게하면 오류가 발생하고 대리인은 정의되지 않습니다. 나는 여기서 뭘해야할지 모르겠다. 죄송합니다, 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
좋습니다,'this.props.deputies'가'render'가 호출 될 때까지 도착하는지 확인하여 시작하는 것이 좋습니다. 그렇지 않은 경우 정의되지 않습니다. 그것은 당신의 첫 번째 단계입니다. 삼항 연산자'this.props.deputies? '를 사용하여 데이터가 도착했는지 체크를 할 수있다. this.props.deputies : [ "Data not arrived"]'- 도착하지 않으면'render is called '할 때 정의되지 않을 것입니다. 코드에는 몇 가지 다른 문제가 있지만 시작하십시오! –