0
2つのフィールドのみを使用して検索コンポーネントをフィルタリングしようとしています。今は、リスト内のすべてのフィールドから結果を返します。特定のフィールドで検索する流星リアクションネイティブ
{
"deputes" : [ {
"depute" : {
"id" : 1,
"id_an" : "718902",
"lieu_naissance" : "Brest (Finistère)",
"nom_circo" : "Alpes-Maritimes",
"nom_de_famille" : "Roussel",
"num_circo" : 3
そして、それを検索するコンポーネントは次のようになります:
class Flat_List extends Component{
constructor(props){
super(props);
console.log(props)
this._handleResults = this._handleResults.bind(this);
this.state = {
data : null
}
}
_handleResults(results){
console.log('handle results')
this.setState({data: results})
}
render() {
let listitems = this.state.data
if (this.state.data == null) {
listitems = this.props.deputies
}
return(
<View>
<SearchBar
ref={(ref) => this.searchBar = ref}
data={this.props.deputies}
handleResults={this._handleResults}
allDataOnEmptySearch = {true}
showOnLoad = {true}
hideBack
autoCorrect= {false}
/>
<List>
<FlatList style={styles.flatListStyle}
data={listitems}
keyExtractor={(item)=> item._id}
renderItem={({item})=>(
<DeputyDetail deputy={item.depute} navigation={this.props.navigation} />)} />
</List>
</View>
私の検索が2であれば、それは何とか2
JSONファイルは、次のようになります含むすべての単一のオブジェクトを返します意味
このコンポーネントはどのように2つのフィールドのみで検索できますか? {num_circo}と{nom}?
をそうでもない他のフィールドを削除するオプションを!結果を表示するには残りのファイルが必要です – Sonia
代理人を新しいオブジェクト、つまりfilteredDepにコピーし、filteredDepのフィールドを削除します。あなたのthis.props.deputiesは同じままです。 –