|
4 | 4 | import React, { Component, Element } from 'react'; |
5 | 5 | import _ from 'lodash'; |
6 | 6 | import moment from 'moment'; |
| 7 | +import { autobind } from 'core-decorators'; |
7 | 8 |
|
8 | 9 | // components |
9 | 10 | import WaitAnimation from 'components/core/wait-animation/wait-animation'; |
@@ -36,7 +37,7 @@ type Props = { |
36 | 37 | title: string, |
37 | 38 | emptyContentTitle: string, |
38 | 39 | paginationSize: number, |
39 | | - onLoadMoreReviews: Function, |
| 40 | + onLoadMoreReviews: (from: number) => Promise<mixed>, |
40 | 41 | showLoadMore: ?boolean, |
41 | 42 | }; |
42 | 43 |
|
@@ -83,10 +84,6 @@ const ReviewBody = (props: ReviewBodyProps): Element<any> => { |
83 | 84 | ); |
84 | 85 | }; |
85 | 86 |
|
86 | | -function incrementPage(nextPage) { |
87 | | - return { page: nextPage }; |
88 | | -} |
89 | | - |
90 | 87 | class ProductReviewsList extends Component { |
91 | 88 |
|
92 | 89 | props: Props; |
@@ -150,12 +147,13 @@ class ProductReviewsList extends Component { |
150 | 147 | ); |
151 | 148 | } |
152 | 149 |
|
153 | | - handleLoadMoreReviews = () => { |
| 150 | + @autobind |
| 151 | + handleLoadMoreReviews() { |
154 | 152 | const { onLoadMoreReviews, paginationSize } = this.props; |
155 | 153 | const { page } = this.state; |
156 | 154 |
|
157 | 155 | const nextPage = page + 1; |
158 | | - this.setState(incrementPage(nextPage)); |
| 156 | + this.setState({page: nextPage}); |
159 | 157 | onLoadMoreReviews(paginationSize * nextPage); |
160 | 158 | } |
161 | 159 |
|
|
0 commit comments