简体   繁体   English

我该如何使用FlatList而不是ListView?

[英]How can I use this with FlatList not with ListView?

I took this code from react-native-gifted-chat and I want to use FlatList 我从react-native-gifted-chat中获取了这段代码,我想使用FlatList

<ListView
      enableEmptySections={true}
      automaticallyAdjustContentInsets={false}
      initialListSize={20}
      pageSize={20}

      {...this.props.listViewProps}

      dataSource={this.state.dataSource}

      renderRow={this.renderRow}
      renderHeader={this.renderFooter}
      renderFooter={this.renderLoadEarlier}
      renderScrollComponent={this.renderScrollComponent}
    />

Here's an example for using FlatList to do what you're trying to do: 这是一个使用FlatList来做您想做的事的例子:

 render() {
    return (
      <View style={{ flex: 1 }}>
        <FlatList
          data={someArrayWithDataObjects} // your data source
          renderItem={({ item }) => this.renderSearchResults(item)} // how you want each item rendered
          keyExtractor={item => item.id} // unique identifier for performance reasons
        />
      </View>
    );
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM