Skip to content

Commit

Permalink
feat(web): add showLoader prop in reactive list
Browse files Browse the repository at this point in the history
  • Loading branch information
bietkul committed May 17, 2019
1 parent 350cd90 commit 7c6241e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/web/src/components/result/ReactiveList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare namespace ReactiveListTree {
paginationAt?: types.paginationAt;
react?: types.react;
showResultStats?: boolean;
showLoader?: boolean;
size?: number;
sortBy?: types.sortBy;
sortOptions?: types.sortOptions;
Expand Down
13 changes: 10 additions & 3 deletions packages/web/src/components/result/ReactiveList.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ class ReactiveList extends Component {
return infiniteScroll && !pagination;
}

get hasCustomRenderer() {
return hasCustomRenderer(this.props);
}

setReact = (props) => {
const { react } = props;
if (react) {
Expand Down Expand Up @@ -679,7 +683,7 @@ class ReactiveList extends Component {
fragmentName={this.props.componentId}
/>
) : null}
{hasCustomRenderer(this.props) ? (
{this.hasCustomRenderer ? (
this.getComponent()
) : (
<div
Expand All @@ -690,12 +694,13 @@ class ReactiveList extends Component {
>
{filteredResults.map((item, index) =>
renderItem(item, () => {
this.triggerClickAnalytics(currentPage * size + index);
const base = currentPage * size;
this.triggerClickAnalytics(base + index);
}),
)}
</div>
)}
{this.props.isLoading && this.showInfiniteScroll
{this.props.showLoader && this.props.isLoading && this.showInfiniteScroll
? this.props.loader || (
<div
style={{
Expand Down Expand Up @@ -786,6 +791,7 @@ ReactiveList.propTypes = {
renderResultStats: types.func,
scrollOnChange: types.bool,
scrollTarget: types.string,
showLoader: types.bool,
showResultStats: types.bool,
size: types.number,
sortBy: types.sortBy,
Expand All @@ -810,6 +816,7 @@ ReactiveList.defaultProps = {
size: 10,
style: {},
URLParams: false,
showLoader: true,
renderNoResults: () => 'No Results found.',
scrollOnChange: true,
defaultSortOption: null,
Expand Down

0 comments on commit 7c6241e

Please sign in to comment.