Code Monkey home page Code Monkey logo

Comments (1)

alloy avatar alloy commented on July 26, 2024

Then something like the following should be enough to add pagination:

diff --git a/lib/components/artist/shows/past_shows.js b/lib/components/artist/shows/past_shows.js
index 6ea1fcf..8e15262 100644
--- a/lib/components/artist/shows/past_shows.js
+++ b/lib/components/artist/shows/past_shows.js
@@ -10,10 +10,14 @@ import SerifText from '../../text/serif'
 import OpaqueImageView from '../../opaque_image_view'
 import ShowMetadata from './show_metadata'

+const PageSize = 10;

 class PastShows extends React.Component {
   constructor(props) {
     super(props);
+
+    this.fetchNextPage = this.fetchNextPage.bind(this);
+
     this.state = {
       dataSource: new ListView.DataSource({
         rowHasChanged:(row1, row2) => row1 !== row2,
@@ -21,12 +25,19 @@ class PastShows extends React.Component {
     };
   }

+  fetchNextPage() {
+    this.props.relay.setVariables({
+      size: this.props.relay.size + PageSize,
+    });
+  }
+
   render() {
     return (
       <ListView
         dataSource={this.state.dataSource}
         renderRow={this.renderShow}
         renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator} />}
+        onEndReached={this.fetchNextPage}
       />
     )
   }
@@ -60,10 +71,13 @@ var styles = StyleSheet.create({
 });

 export default Relay.createContainer(PastShows, {
+  initialVariables: {
+    size: PageSize
+  },
   fragments: {
     artist: () => Relay.QL`
       fragment on Artist {
-        partner_shows(status: "closed") {
+        partner_shows(status: "closed", size: $size) {
           meta_image {
             cropped(width: 75, height: 75) {
               url

from emission.

Related Issues (20)

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.