Giter Site home page Giter Site logo

react-native-refresher's Introduction

A pull to refresh ListView for React Native completely written in js. Also supports custom animations.

Installation

npm install react-native-refresher --save

Usage

var React = require('react-native');
// Loading the refresher ListView and Indicator
var {
  RefresherListView,
  LoadingBarIndicator
} = require('react-native-refresher');

var {
  AppRegistry,
  Text,
  View,
  ListView,
} = React;


class Content extends React.Component {
  constructor() {
    super();
    this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.state = {
      dataSource: this.ds.cloneWithRows(["Row 1", "Row 2"]),
    };
  }
  onRefresh() {
  	// You can either return a promise or a callback
    this.setState({dataSource:this.fillRows(["Row 1", "Row 2", "Row 3", "Row 4"])});
  }
  render() {
    return (
      <View style={{flex:1}}>
        <RefresherListView
          dataSource={this.state.dataSource}
          onRefresh={this.onRefresh.bind(this)}
          indicator={<LoadingBarIndicator />}
          renderRow={(rowData) => <View style={{padding:10,borderBottomColor: '#CCCCCC', backgroundColor: 'white',borderBottomWidth: 1}}><Text>{rowData}</Text></View>}
        />
      </View>
    );
  }
};

Examples

Refresher: iOS Activity Indicator Refresher: Bar Indicator

Props

  • threshold: number The amount of pixeles to validate the refresh. By default the theshold will be calculated by the header height.
  • minTime: number The minimum amount of time for showing the loading indicator while is refreshing. Default 320ms.
  • onRefresh: func.isRequired Called when user pulls listview down to refresh.
  • indicator: oneOfType([element]) React Element. See example of a custom indicator
  • refreshOnRelease: bool If is necessary to release touch for refresh or refresh will be done automatically once threshold is passed.
  • listStyle: style The list style

Credits

Refresher is created by Syrus Akbary and inspired by Refresher and react-native-refreshable-listview. If you have suggestions or bug reports, feel free to send pull request or create new issue.

react-native-refresher's People

Contributors

paramaggarwal avatar seigel avatar sosaucily avatar syrusakbary 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

react-native-refresher's Issues

Some problems.

I used LoadingBarIndicator. It worked but not like yours.
Refresher: Bar Indicator

Pass event prop down to onScroll()

Hello,

Playing with this component, but getting an error when I pass my onScroll function to it. The component doesn't seem to be passing the event prop into the function. Is there a reason you're doing this? If not, would you accept a PR to fix it?

Current
this.props.onScroll && this.props.onScroll();

Proposed
this.props.onScroll && this.props.onScroll(e);

Thanks!

onRefresh not called & warnings in packager

Hi,

Thanks for sharing your work. It appears that the onRefresh function is not getting called at all on pull and release - I stuck in a console.log() somewhere in the function and even that is not getting hit at all. Please what could be missing? My list seems to work normal as before, no errors there.

Except for these warnings in the packager:

Unable to resolve module precomputeStyle from /Code/MyApp/node_modules/react-native-refresher/lib/RefresherListView.js Unable to resolve module logError from /Code/MyApp/node_modules/react-native-refresher/lib/RefresherListView.js Unable to resolve module NativeMethodsMixin from /Code/MyApp/node_modules/react-native-refresher/lib/indicators/LoadingBarIndicator.js

renderHeader won't work

Porting existing ListView with renderHeader function to RefresherListView will not render the header view

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.