@@ -86,12 +86,11 @@ const FlatList = forwardRef((props: Props, ref: Ref<HTMLElement>) => {
86
86
sortBy, sortDesc, sort, sortCaseInsensitive, sortGroupBy, sortGroupDesc, // sort props
87
87
searchBy, searchOnEveryWord, searchTerm, searchCaseInsensitive, // search props
88
88
display, displayRow, rowGap, displayGrid, gridGap, minColumnWidth, // display props,
89
- hasMoreItems, loadMoreItems, paginationLoadingIndicator, paginationLoadingIndicatorPosition,
90
- pagination, // pagination props
89
+ hasMoreItems, loadMoreItems, paginationLoadingIndicator, paginationLoadingIndicatorPosition, // pagination props
91
90
...otherProps // props to be added to the wrapper container if wrapperHtmlTag is specified
92
91
} = props ;
93
92
// tslint:disable-next-line:prefer-const
94
- let { list, group, search, ...tagProps } = otherProps ;
93
+ let { list, group, search, pagination , ...tagProps } = otherProps ;
95
94
96
95
list = convertListToArray ( list ) ;
97
96
@@ -209,6 +208,13 @@ const FlatList = forwardRef((props: Props, ref: Ref<HTMLElement>) => {
209
208
} ) ;
210
209
}
211
210
211
+ if ( pagination && pagination . loadMore ) {
212
+ pagination = {
213
+ ...( FlatList . defaultProps && FlatList . defaultProps . pagination ) ,
214
+ ...pagination
215
+ } ;
216
+ }
217
+
212
218
const content = (
213
219
< Fragment >
214
220
{
@@ -222,7 +228,7 @@ const FlatList = forwardRef((props: Props, ref: Ref<HTMLElement>) => {
222
228
{ ...{ display, displayRow, rowGap, displayGrid, gridGap, minColumnWidth} }
223
229
showGroupSeparatorAtTheBottom = { group . separatorAtTheBottom || showGroupSeparatorAtTheBottom }
224
230
/>
225
- { ( loadMoreItems || pagination . loadMore ) &&
231
+ { ( loadMoreItems || ( pagination && pagination . loadMore ) ) &&
226
232
< InfiniteLoader
227
233
hasMore = { hasMoreItems || pagination . hasMore }
228
234
loadMore = { loadMoreItems || pagination . loadMore }
@@ -324,6 +330,15 @@ FlatList.propTypes = {
324
330
* the minimum column width when display grid is activated
325
331
*/
326
332
minColumnWidth : string ,
333
+ /**
334
+ * a pagination shorthand configuration
335
+ */
336
+ pagination : shape ( {
337
+ hasMore : bool ,
338
+ loadMore : func ,
339
+ loadingIndicator : oneOfType ( [ node , func , element ] ) ,
340
+ loadingIndicatorPosition : string ,
341
+ } ) ,
327
342
/**
328
343
* a custom element to be used instead of the default loading indicator for pagination
329
344
*/
@@ -441,6 +456,12 @@ FlatList.defaultProps = {
441
456
limit : 0 ,
442
457
loadMoreItems : null ,
443
458
minColumnWidth : '' ,
459
+ pagination : {
460
+ hasMore : false ,
461
+ loadMore : null ,
462
+ loadingIndicator : null ,
463
+ loadingIndicatorPosition : '' ,
464
+ } ,
444
465
paginationLoadingIndicator : undefined ,
445
466
paginationLoadingIndicatorPosition : '' ,
446
467
renderWhenEmpty : null ,
0 commit comments