iwater/react-native-infinite-virtualized-list

TypeError: Cannot read property 'length' of undefined

Opened this issue · 0 comments

TypeError: Cannot read property 'length' of undefined, when loading the screen.

Versions:
react-native: 0.58.6
react: 16.5.0
react-native-infinite-virtualized-list: 0.1.14

Code

import GiftedListView from 'react-native-infinite-virtualized-list';

onFetch(page = 1, callback, options) {
    setTimeout(() => {
      var rows = ['row '+((page - 1) * 3 + 1), 'row '+((page - 1) * 3 + 2), 'row '+((page - 1) * 3 + 3)];
      if (page === 3) {
        callback(rows, {
          allLoaded: true, // the end of the list is reached
        });
      } else {
        callback(rows);
      }
    }, 1000); // simulating network fetching
}

renderRowView(rowData) {
    return (
      <TouchableHighlight
        style={styles.row}
        underlayColor='#c8c7cc'
        onPress={() => this._onPress(rowData)}
      >
        <Text>{rowData}</Text>
      </TouchableHighlight>
    );
  }

render() {
    return (
      <View>
        <GiftedListView
          rowView={this.renderRowView}
          onFetch={this.onFetch}
          firstLoader={true} // display a loader for the first fetching
          pagination={true} // enable infinite scrolling using touch to load more
          refreshable={true} // enable pull-to-refresh for iOS and touch-to-refresh for Android
          withSections={false} // enable sections
          customStyles={{
            paginationView: {
              backgroundColor: '#eee',
            },
          }}

          refreshableTintColor="blue"
          keyExtractor={(item, index) => index} // you need this for VirtualizedList
        />
      </View>
    );
  }