Created
February 19, 2016 17:07
-
-
Save josercruz01/ebcb3413f0855ccd2041 to your computer and use it in GitHub Desktop.
Revisions
-
josercruz01 revised this gist
Feb 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class NewCandidates extends React.Component { export default Relay.createContainer(NewCandidates, { initialVariables: { pageSize: pageSize }, fragments: { viewer: () => Relay.QL` -
josercruz01 created this gist
Feb 19, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ import Relay from "react-relay"; import React from "react"; import ReactList from "react-list"; const pageSize = 30; class NewCandidates extends React.Component { constructor(props){ super(props); this.renderRow = this.renderRow.bind(this); } renderRow(key, index) { var candidates = this.props.viewer.newCandidates.edges; // End of the list reached. Increase page size. Relay // will fetch only the required data to fill the new // page size. if (index === candidates.length - 1) { this.props.relay.setVariables({ pageSize: candidates.length + pageSize }); } var candidate = candidates[index].node; return ( <li key={ key }> Id: { candidate.recordId }, Name: { candidate.name }</li> ); } render() { var candidates = this.props.viewer.newCandidates; return ( <ul style={{ height: 200, overflowY: "scroll"}}> <ReactList itemRenderer={ this.renderRow} length={ candidates.edges.length }/> </ul> ); } } export default Relay.createContainer(NewCandidates, { initialVariables: { pageSize: 30 }, fragments: { viewer: () => Relay.QL` fragment on User { newCandidates(first: $pageSize) { edges { node { recordId, name } } } } ` } });