mirror of
https://github.com/zhigang1992/react-native-super-grid.git
synced 2026-01-12 22:50:58 +08:00
Preserve original keys of section when passing down to SectionList
This commit is contained in:
@@ -88,6 +88,9 @@ import { SectionGrid } from 'react-native-super-grid';
|
||||
|
||||
All additional props you pass will be passed on to the internal FlatList/SectionList. This means you can make use of various props and methods like `ListHeaderComponent`, `onEndReached`, `onRefresh`...etc. While these are not tested for compatibility, most of them should work as expected.
|
||||
|
||||
In **SectionGrid**, `section` argument in methods like `renderSectionHeader`, `renderSectionFooter`, `ItemSeparatorComponent` will slightly different from the actual section you passed. The `data` key in the `section` will be the grouped versions of items (items that go in one row), and the original list of items can be found in `originalData` key. All other keys will remain intact.
|
||||
|
||||
|
||||
## FlatGrid Example
|
||||
```javascript
|
||||
import React, { Component } from 'react';
|
||||
|
||||
@@ -92,7 +92,6 @@ class SectionGrid extends Component {
|
||||
itemDimension,
|
||||
staticDimension,
|
||||
renderItem,
|
||||
renderSectionHeader,
|
||||
onLayout,
|
||||
...restProps
|
||||
} = this.props;
|
||||
@@ -119,9 +118,9 @@ class SectionGrid extends Component {
|
||||
const chunkedData = chunkArray(section.data, itemsPerRow);
|
||||
|
||||
return {
|
||||
title: section.title,
|
||||
...section,
|
||||
data: chunkedData,
|
||||
actualSection: section,
|
||||
originalData: section.data,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -129,11 +128,10 @@ class SectionGrid extends Component {
|
||||
return (
|
||||
<SectionList
|
||||
sections={groupedSections}
|
||||
renderSectionHeader={renderSectionHeader}
|
||||
renderItem={({ item, index, section }) => this.renderRow({
|
||||
rowItems: item,
|
||||
rowIndex: index,
|
||||
section: section.actualSection,
|
||||
section: section,
|
||||
isFirstRow: index === 0,
|
||||
itemsPerRow,
|
||||
rowStyle,
|
||||
|
||||
Reference in New Issue
Block a user