import React, { PropTypes } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { loadEntries } from '../actions/entries'; import { selectEntries } from '../reducers'; import { Loader } from '../components/UI'; import EntryListing from '../components/EntryListing/EntryListing'; class CollectionPage extends React.Component { static propTypes = { collection: ImmutablePropTypes.map.isRequired, collections: ImmutablePropTypes.orderedMap.isRequired, publicFolder: PropTypes.string.isRequired, dispatch: PropTypes.func.isRequired, page: PropTypes.number, entries: ImmutablePropTypes.list, }; componentDidMount() { const { collection, dispatch } = this.props; if (collection) { dispatch(loadEntries(collection)); } } componentWillReceiveProps(nextProps) { const { collection, dispatch } = this.props; if (nextProps.collection !== collection) { dispatch(loadEntries(nextProps.collection)); } } handleLoadMore = (page) => { const { collection, dispatch } = this.props; dispatch(loadEntries(collection, page)); }; render() { const { collections, collection, publicFolder, page, entries } = this.props; if (collections == null) { return