mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
add PropTypes to LoadMore component
This commit is contained in:
@@ -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}/>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user