add PropTypes to LoadMore component

This commit is contained in:
Riley Davis
2017-02-14 15:27:36 -07:00
parent 714c251c77
commit 63982aa241
2 changed files with 22 additions and 13 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ class Embed extends Component {
notification={{text: null}}
/>
<LoadMore
id={asset.id}
asset_id={asset.id}
comments={asset.comments}
moreComments={asset.commentCount > asset.comments.length}
loadMore={this.props.loadMore}/>
+21 -12
View File
@@ -1,10 +1,10 @@
import React from 'react';
import React, {PropTypes} from 'react';
import I18n from 'coral-framework/modules/i18n/i18n';
import translations from 'coral-framework/translations.json';
import {Button} from 'coral-ui';
const lang = new I18n(translations);
const loadMoreComments = (id, comments, loadMore) => {
const loadMoreComments = (asset_id, comments, loadMore) => {
if (!comments.length) {
return;
@@ -13,19 +13,28 @@ const loadMoreComments = (id, comments, loadMore) => {
loadMore({
limit: 10,
cursor: comments[comments.length - 1].created_at,
asset_id: id,
asset_id,
sort: 'REVERSE_CHRONOLOGICAL'
});
};
const LoadMore = ({id, comments, loadMore, moreComments}) => moreComments ?
<Button
className='coral-load-more'
onClick={() => loadMoreComments(id, comments, loadMore)}>
{
lang.t('loadMore')
}
</Button>
: null;
const LoadMore = ({asset_id, comments, loadMore, moreComments}) => (
moreComments
? <Button
className='coral-load-more'
onClick={() => loadMoreComments(asset_id, comments, loadMore)}>
{
lang.t('loadMore')
}
</Button>
: null
);
LoadMore.propTypes = {
asset_id: PropTypes.string.isRequired,
comments: PropTypes.array.isRequired,
moreComments: PropTypes.bool.isRequired,
loadMore: PropTypes.func.isRequired
};
export default LoadMore;