{"id":21126114,"url":"https://github.com/shigebeyond/react-native-sk-refreshable-listview","last_synced_at":"2025-07-08T23:31:46.377Z","repository":{"id":57340132,"uuid":"53478021","full_name":"shigebeyond/react-native-sk-refreshable-listview","owner":"shigebeyond","description":"Component wrap ListView, supports: 1 pull up to refresh 2 pull down to load more 3 scroll to top 4 scroll to bottom","archived":false,"fork":false,"pushed_at":"2016-03-11T08:47:04.000Z","size":142,"stargazers_count":37,"open_issues_count":4,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-19T08:53:25.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shigebeyond.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-09T07:40:40.000Z","updated_at":"2022-03-28T17:27:47.000Z","dependencies_parsed_at":"2022-08-26T04:30:29.790Z","dependency_job_id":null,"html_url":"https://github.com/shigebeyond/react-native-sk-refreshable-listview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shigebeyond/react-native-sk-refreshable-listview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigebeyond%2Freact-native-sk-refreshable-listview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigebeyond%2Freact-native-sk-refreshable-listview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigebeyond%2Freact-native-sk-refreshable-listview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigebeyond%2Freact-native-sk-refreshable-listview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shigebeyond","download_url":"https://codeload.github.com/shigebeyond/react-native-sk-refreshable-listview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigebeyond%2Freact-native-sk-refreshable-listview/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262049685,"owners_count":23250795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T04:39:12.365Z","updated_at":"2025-07-08T23:31:46.115Z","avatar_url":"https://github.com/shigebeyond.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-sk-refreshable-listview\n\n##What is it\n\nreact-native-sk-refreshable-listview is a component wraps ListView, supports: 1 pull down to refresh 2 pull up to load more 3 scroll to top 4 scroll to bottom\n\n##How to use it\n\n1. `npm install react-native-sk-refreshable-listview@latest --save`\n\n2. Write this in index.ios.js / index.android.js\n\n```javascript\n\n'use strict';\nimport React, {\n  AppRegistry,\n  StyleSheet,\n  Text,\n  View,\n  Dimensions,\n} from 'react-native';\n\n\nvar RefreshableListView = require('react-native-sk-refreshable-listview');\nvar {width, height} = Dimensions.get('window');\nvar dataUrl = 'https://raw.githubusercontent.com/shigebeyond/react-native-sk-refreshable-listview/master/test.json';\nvar data = [\n {id: 1, text: 'row 1'},\n {id: 2, text: 'row 2'},\n {id: 3, text: 'row 3'},\n {id: 4, text: 'row 4'},\n {id: 5, text: 'row 5'},\n {id: 6, text: 'row 6'},\n {id: 7, text: 'row 7'},\n {id: 8, text: 'row 8'},\n {id: 9, text: 'row 9'},\n {id: 10, text: 'row 10'},\n];\n\n// simulate fetch()\nfunction skFetch(url){\n  return new Promise((resolve, reject) =\u003e {\n    setTimeout(() =\u003e {\n      resolve(data);\n    }, 1000)\n  });\n}\n\nvar test = React.createClass({\n  getInitialState() {\n     return {\n       dataSource : new RefreshableListView.DataSource({rowHasChanged : (row1, row2) =\u003e  row1 !== row2}),\n     }\n   },\n   componentDidMount() {\n     this.fetchData(true);\n   },\n\n   /**\n    * load data\n    * @param bool refresh: whether to refresh data, or load more data\n    * @return Promise\n    */\n   fetchData(refresh){\n     if(refresh){\n       this.nextPage = 1;\n     }\n     // get the data url of next page\n     var nextDataUrl = dataUrl + '?page=' + this.nextPage;\n     // I use skFetch() to simulate fetch()\n     return skFetch(nextDataUrl)\n       .then((result) =\u003e {\n         var newRows;\n         if(refresh){ // set rows of dataSource\n           newRows = result;\n         }else{// add new rows into dataSource\n           newRows = this.getRows().concat(result);\n         }\n         var newDataSource = this.state.dataSource.cloneWithRows(newRows);\n         this.setState({\n           dataSource: newDataSource,\n         });\n         this.nextPage++;\n       }).catch((e)=\u003e{\n         console.log(e);\n       });\n       //.done();\n  },\n\n   // get all rows of dataSource\n  getRows() {\n     var result = this.state.dataSource \u0026\u0026 this.state.dataSource._dataBlob \u0026\u0026 this.state.dataSource._dataBlob.s1;\n     return result ? result : [];\n  },\n\n  // whether no row in dataSource\n  isEmpty(){\n    return this.getRows().length == 0;\n  },\n\n  renderRow(row) {\n    return (\n      \u003cView style={styles.row} \u003e\n        \u003cText\u003e{row.text}\u003c/Text\u003e\n      \u003c/View\u003e\n    );\n  },\n\n  render() {\n    if(this.isEmpty()){\n      return (\n        \u003cView style={styles.emptyBox}\u003e\n          \u003cText style={styles.emptyTxt}\u003e{'Please pull down to fresh data, \\n pull up to load more data'}\u003c/Text\u003e\n        \u003c/View\u003e\n      )\n    }\n    return (\n      \u003cRefreshableListView\n        style={styles.container}\n        dataSource={this.state.dataSource} // set dataSource\n        onRefresh={() =\u003e this.fetchData(true)} // callback to refresh data (load first page of data), which should return a Promise, I use this promise to tell when to stop loading (render loading view).\n        onLoadMore={() =\u003e this.fetchData(false)} // callback to load more data (load next page of data), which should return a Promise, I use this promise to tell when to stop loading (render loading view)\n        showLoadMore={true}\n        renderRow={this.renderRow}\n      /\u003e\n    );\n  }\n});\n\nvar styles = {\n  emptyBox: {\n    flex: 1,\n    justifyContent: 'center',\n    alignItems: 'center'\n  },\n  emptyTxt: {\n    fontSize: 23,\n    fontWeight: 'bold'\n  },\n  container: {\n    flex: 1,\n    backgroundColor: '#FFF',\n  },\n  row: {\n    padding: 10,\n    height: height / 10,\n    backgroundColor: 'yellow',\n    borderBottomColor: 'grey',\n    borderBottomWidth: 2,\n  },\n};\n\nAppRegistry.registerComponent('test', () =\u003e test);\n\n```\n![](https://raw.githubusercontent.com/shigebeyond/react-native-sk-refreshable-listview/master/demo.gif)\n\n##Properties\n\nAny [View property](http://facebook.github.io/react-native/docs/view.html) and the following:\n\n| Prop | Description | Default |\n|---|---|---|\n|**`onRefresh`**|callback to refresh data (load first page of data), which should return a Promise, I use this promise to tell when to stop loading (render loading view). |*None*|\n|**`onLoadMore`**|callback to load more data (load next page of data), which should return a Promise, I use this promise to tell when to stop loading (render loading view). |*None*|\n\n##Methods\n\n| Method | Description | Params |\n|---|---|---|\n|**`scrollToTop`**|scroll to top. |*None*|\n|**`scrollToBottom`**|scroll to bottom. |*None*|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigebeyond%2Freact-native-sk-refreshable-listview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshigebeyond%2Freact-native-sk-refreshable-listview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigebeyond%2Freact-native-sk-refreshable-listview/lists"}