Skip to content

Instantly share code, notes, and snippets.

@flarnie
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flarnie/57f9e9cc8838dcd30176 to your computer and use it in GitHub Desktop.
Save flarnie/57f9e9cc8838dcd30176 to your computer and use it in GitHub Desktop.
React-Waypoint Infinite Scroll Step 3
var InfiniteScrollExample = React.createClass({
_loadMoreItems: function() {
this.setState({ loading: true });
// Do the fetching of data here with AJAX
// In this fake example we just generate more image urls
// and set the state of 'loading' to false.
// ...
},
getInitialState: function() {
// set up list of items ...
},
_renderItems: function() {
return this.state.items.map(function(imageUrl, index) {
// ... generate list items here ...
});
},
_renderWaypoint: function() {
if (!this.state.isLoading) {
return (
<Waypoint
onEnter={this._loadMoreItems}
threshold={2.0}
/>
);
}
},
render: function() {
return (
<div className="infinite-scroll-example">
<div className="infinite-scroll-example__scrollable-parent">
{this._renderItems()}
{this._renderWaypoint()}
</div>
</div>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment