GithubHelp home page GithubHelp logo

iwater / react-native-infinite-virtualized-list Goto Github PK

View Code? Open in Web Editor NEW
34.0 4.0 4.0 11 KB

A new InfiniteList that compose react-virtualized/InfiniteLoader with the react-native/VirtualizedList component, and a drop replacement component of react-native-gifted-listview

License: MIT License

JavaScript 100.00%
react-native virtualized infinite-scrolling virtualizedlist

react-native-infinite-virtualized-list's Introduction

Gifted ListView

A new InfiniteList for react-native 0.43+ that compose react-virtualized/InfiniteLoader with the new react-native/VirtualizedList component, and a drop replacement component of react-native-gifted-listview

Changelog

0.1.5

  • Pull-to-refresh

0.1.4

  • react-native 0.43.0+

0.1.0

  • the first version

GiftedListView Simple example

below code was take from react-native-gifted-listview just replace one line

var React = require('react-native');
var {
  StyleSheet,
  Text,
  View,
  TouchableHighlight
} = React;


// var GiftedListView = require('react-native-gifted-listview');
import { GiftedListView } from 'react-native-infinite-virtualized-list'

var Example = React.createClass({

  /**
   * Will be called when refreshing
   * Should be replaced by your own logic
   * @param {number} page Requested page to fetch
   * @param {function} callback Should pass the rows
   * @param {object} options Inform if first load
   */
  _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
  },


  /**
   * When a row is touched
   * @param {object} rowData Row data
   */
  _onPress(rowData) {
    console.log(rowData+' pressed');
  },

  /**
   * Render a row
   * @param {object} rowData Row data
   */
  _renderRowView(rowData) {
    return (
      <TouchableHighlight
        style={styles.row}
        underlayColor='#c8c7cc'
        onPress={() => this._onPress(rowData)}
      >
        <Text>{rowData}</Text>
      </TouchableHighlight>
    );
  },

  render() {
    return (
      <View style={styles.container}>
        <View style={styles.navBar} />
        <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>
    );
  }
});

var styles = {
  container: {
    flex: 1,
    backgroundColor: '#FFF',
  },
  navBar: {
    height: 64,
    backgroundColor: '#CCC'
  },
  row: {
    padding: 10,
    height: 44,
  },
};

InfiniteVirtualizedList Advanced example

See src/GiftedVirtualizedList.js

Installation

npm install react-native-infinite-virtualized-list --save

Features

  • Pull-to-refresh
  • Infinite scrolling
  • Loader for first display
  • Default view when no content to display
  • Customizable (see advanced example)

License

MIT

react-native-infinite-virtualized-list's People

Contributors

iwater avatar lekenny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-infinite-virtualized-list's Issues

`paginationWaitingView` is not required

@iwater

when i copy the example from README, got this warning,

Warning: Failed prop type: The prop `paginationWaitingView` is marked as required in `GiftedVirtualizedList`, but its value is `undefined`.

yes, in here, it is isRequired,

paginationWaitingView: PropTypes.func.isRequired,

but, where it used,

here:

paginationWaitingView: PropTypes.func,

and default:

static defaultProps = {
paginationWaitingView: noop,
}

so, i think you should remove the isRequired from API.

TypeError: Cannot read property 'length' of undefined

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>
    );
  }

emptyView() - Undefined is not a function

I'm using by the first time this library, looks everything is ok here in my project, but when i'll open the screen with the list view, i'm getting the error:

"undefined is not a function (evaluating 'emptyView()')
render
GiftedVirtualizedList.js:69. _

Any idea about what is harpennig?
And how can I use my list inside the infinity list view? The list variable is alredy declared inside the render() method..

Thank you!

Can I use this for a calendar?

Hey there,

I'm a bit confused.
I'm building a calendar, and I was wondering if I can use this implementation as a month view, so that the user can scroll backwards or forward infinite times.

I noticed there's only an onNextPage callback, but what about previous pages (a.k.a previous months)?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.