React Native Search Filter适用于Android,而非IOS

时间:2019-07-22 20:40:22

标签: ios reactjs search native expo

为本地本机应用程序创建了搜索功能。在世博会上工作。分发以在Google Play和Apple上进行测试。 Android版本工作正常。 IOS版本不过滤任何结果。看我的代码。似乎很简单-没有错误-但没有更新的列表。

...   searchFilterFunction =文本=> {     this.setState({       值:文字     });

let filteredData = this.props.navigation.state.params.animalList.filter(
  item => {
    return item.animalId.includes(text);
  }
);
this.setState({ filteredData: filteredData });};  renderHeader = () => {
return (
  <SearchBar
    placeholder="Search by ID..."
    placeholderTextColor={'white'}
    darkTheme
    containerStyle={{ backgroundColor: "#ccb266", marginLeft: -2, marginRight: -2 }}
    round
    icon={{ color: "white" }}
    onChangeText={text => this.searchFilterFunction(text)}
    autoCorrect={false}
    value={this.state.value}
  />
);

};

...

我希望FlatList可以像在Android上一样在IOS上更新。

FlatList在代码的后面:

        <FlatList
      data={
        this.state.filteredData && this.state.filteredData.length > 0
          ? this.state.filteredData
          : this.props.navigation.state.params.animalList
      }
      showsVerticalScrollIndicator={false}
      contentContainerStyle={{justifyContent: 'center', backgroundColor: '#493e3a', marginLeft: 20, marginRight: 20}}
      extraData={this.props}
      ListHeaderComponent={this.renderHeader}          
      style={styles.myFlatCard}
      ItemSeparatorComponent={this.renderSeparator}          
      refreshControl={
        <RefreshControl
          refreshing={this.state.refresh}
          onRefresh={this._loadActiveList}
        />
      }

0 个答案:

没有答案