From 63982aa24197a7eea4c43301dfc3b2251d4591fc Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 14 Feb 2017 15:27:36 -0700 Subject: [PATCH] add PropTypes to LoadMore component --- client/coral-embed-stream/src/Embed.js | 2 +- client/coral-embed-stream/src/LoadMore.js | 33 ++++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index e5eec37cb..86510a74d 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -160,7 +160,7 @@ class Embed extends Component { notification={{text: null}} /> asset.comments.length} loadMore={this.props.loadMore}/> diff --git a/client/coral-embed-stream/src/LoadMore.js b/client/coral-embed-stream/src/LoadMore.js index e871af410..faf3299e8 100644 --- a/client/coral-embed-stream/src/LoadMore.js +++ b/client/coral-embed-stream/src/LoadMore.js @@ -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 ? - - : null; +const LoadMore = ({asset_id, comments, loadMore, moreComments}) => ( + moreComments + ? + : null +); + +LoadMore.propTypes = { + asset_id: PropTypes.string.isRequired, + comments: PropTypes.array.isRequired, + moreComments: PropTypes.bool.isRequired, + loadMore: PropTypes.func.isRequired +}; export default LoadMore;