react-native#VirtualizedList JavaScript Examples

The following examples show how to use react-native#VirtualizedList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotifyList.js    From bluezone-app with GNU General Public License v3.0 6 votes vote down vote up
render() {
    const {data} = this.props;
    return (
      <VirtualizedList
        onScroll={this.handleOnScroll}
        data={data.items}
        initialNumToRender={4}
        renderItem={this.renderItem}
        keyExtractor={this.keyExtractor}
        getItemCount={this.getItemCount}
        getItem={this.getItem}
      />
    );
  }
Example #2
Source File: recordedWalks.js    From intentional-walk with MIT License 5 votes vote down vote up
export default function RecordedWalksScreen({navigation}) {
  const [recordedWalks, setRecordedWalks] = useState(null);

  useEffect(() => {
    Realm.getWalks().then(walks => setRecordedWalks(walks));
    /// also synchronize with server
    Realm.syncWalks();
  }, []);

  return (
    <SafeAreaView style={GlobalStyles.container}>
      {recordedWalks && (
        <VirtualizedList
          style={styles.list}
          data={recordedWalks}
          getItemCount={data => data.length + 1}
          getItem={(data, i) => (i === 0 ? {id: ''} : data[i - 1])}
          renderItem={({item}) => {
            if (item.id !== '') {
              return (
                <RecordedWalk style={styles.walk} key={item.id} walk={item} />
              );
            } else {
              return (
                <>
                  <PageTitle
                    style={styles.pageTitle}
                    title={Strings.common.myRecordedWalks}
                  />
                  {recordedWalks.length === 0 && (
                    <RecordedWalk
                      style={styles.walk}
                      title={Strings.common.noWalksYet}
                    />
                  )}
                </>
              );
            }
          }}
          keyExtractor={item => item.id}
        />
      )}
    </SafeAreaView>
  );
}