2016-11-08 4 views
0

Ich kann nicht herausfinden, was ich falsch mache, aber ich kann nicht arbeiten, indem ich neue Werte über die Variable ändern.this.props.relay.setVariables() holt keine neuen Ergebnisse (aber verändere auch die Variablen)

Hier ist ein Teil meines Relais Container Code (auf initial es funktioniert gut und holen ersten 5 Ergebnisse):

export const Account = Relay.createContainer(_Account, { 
    initialVariables: { 
    activities: 5 
    }, 

    fragments: { 
    account:() => Relay.QL` 
     fragment on NodeInterface { 
     id 
     ... on Member { 
      activities(first: $activities) { 
      totalCount 
      edges { 
       node { 
       id 
       } 
      } 
      } 
     } 
     } 
    ` 
    }, 
}); 

Hier ist ein Teil der Komponente reagieren, was Relais Variable ändert:

export class _Account extends React.Component { 

    constructor(props) { 
    super(props); 
    this.state = { 
     activities: 5 
    }; 
    } 

    loadMoreActivities(e) { 
    e.preventDefault(); 
    this.setState((state,props) => { 
     const next = state.activities + 5; 
     this.props.relay.setVariables({ 
     activities: next 
     }); 
     return { activities: next } 
    }); 
    } 

    render() { 
    return (
     <div> 

       <div>{ this.state.activities.toString() } - { this.props.relay.variables.activities.toString() }</div> 
       <ProfileActivityList 
       activities={this.props.account.activities} 
       loadMore={this.loadMoreActivities.bind(this)} /> 
       } 
     </div> 
    ); 
    } 
} 

Antwort

0

Ich finde heraus, was falsch ist. pageInfo Daten sind wichtig für die Paginierung. Ich füge einfach pageInfo zur Abfrage hinzu und alles funktioniert wie freigestellt.

Verwandte Themen