class ImageList extends React.Component { constructor(props) { super(props); this.state = { images: [], hasMore: false, page: 0 }; } componentDidMount() { $.getJSON('/images/all', data => { this.setState({ images: data.images, hasMore: data.hasMore }); }); } loadMore() { this.state.page++; $.getJSON('/images/all/' + this.state.page, data => { this.setState({ images: this.state.images.concat(data.images), hasMore: data.hasMore }); }); } render() { var images = this.state.images.map(function(image) { return (