@@ -44,6 +44,7 @@ var GiftedListView = React.createClass({
44
44
headerView : null ,
45
45
sectionHeaderView : null ,
46
46
withSections : false ,
47
+ autoPaginate : false ,
47
48
onFetch ( page , callback , options ) { callback ( [ ] ) ; } ,
48
49
49
50
paginationFetchigView : null ,
@@ -72,6 +73,7 @@ var GiftedListView = React.createClass({
72
73
headerView : React . PropTypes . func ,
73
74
sectionHeaderView : React . PropTypes . func ,
74
75
withSections : React . PropTypes . bool ,
76
+ autoPaginate : React . PropTypes . bool ,
75
77
onFetch : React . PropTypes . func ,
76
78
77
79
paginationFetchigView : React . PropTypes . func ,
@@ -216,6 +218,14 @@ var GiftedListView = React.createClass({
216
218
< View style = { [ this . defaultStyles . separator , this . props . customStyles . separator ] } />
217
219
) ;
218
220
} ,
221
+ onEndReached ( ) {
222
+ if ( this . props . autoPaginate ) {
223
+ this . _onPaginate ( ) ;
224
+ }
225
+ if ( this . props . onEndReached ) {
226
+ this . props . onEndReached ( ) ;
227
+ }
228
+ } ,
219
229
220
230
getInitialState ( ) {
221
231
@@ -286,10 +296,13 @@ var GiftedListView = React.createClass({
286
296
} ,
287
297
288
298
_onPaginate ( ) {
289
- this . setState ( {
290
- paginationStatus : 'fetching' ,
291
- } ) ;
292
- this . props . onFetch ( this . _getPage ( ) + 1 , this . _postPaginate , { } ) ;
299
+ if ( this . state . paginationStatus === 'firstLoad'
300
+ || this . state . paginationStatus === 'waiting' ) {
301
+ this . setState ( {
302
+ paginationStatus : 'fetching' ,
303
+ } ) ;
304
+ this . props . onFetch ( this . _getPage ( ) + 1 , this . _postPaginate , { } ) ;
305
+ }
293
306
} ,
294
307
295
308
_postPaginate ( rows = [ ] , options = { } ) {
@@ -418,6 +431,8 @@ var GiftedListView = React.createClass({
418
431
419
432
renderSeparator = { this . renderSeparator }
420
433
434
+ onEndReached = { this . onEndReached }
435
+
421
436
{ ...this . props }
422
437
423
438
style = { [ this . props . style , style ] }
0 commit comments