Skip to content

Commit 0e4411d

Browse files
authored
Merge pull request facebook#958 from hramos/flatlist-docs
[FlatList] Add note on multi-column layouts
2 parents 043abd5 + fc35d77 commit 0e4411d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/flatlist.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A performant interface for rendering simple, flat lists, supporting the most han
1414
- Pull to Refresh.
1515
- Scroll loading.
1616
- ScrollToIndex support.
17+
- Multiple column support.
1718

1819
If you need section support, use [`<SectionList>`](sectionlist.md).
1920

@@ -26,6 +27,8 @@ Minimal Example:
2627
/>
2728
```
2829

30+
To render multiple columns, use the [`numColumns`](flatlist.md#numcolumns) prop. Using this approach instead of a `flexWrap` layout can prevent conflicts with the item height logic.
31+
2932
More complex, multi-select example demonstrating `PureComponent` usage for perf optimization and avoiding bugs.
3033

3134
- By binding the `onPressItem` handler, the props will remain `===` and `PureComponent` will prevent wasteful re-renders unless the actual `id`, `selected`, or `title` props change, even if the components rendered in `MyListItem` did not have such optimizations.
@@ -149,7 +152,7 @@ Also inherits [ScrollView Props](scrollview.md#props), unless it is nested in an
149152
### `renderItem`
150153

151154
```javascript
152-
renderItem({ item: Object, index: number, separators: { highlight: Function, unhighlight: Function, updateProps: Function(select: string, newProps: Object) } }) => ?React.Element
155+
renderItem({item, index, separators});
153156
```
154157

155158
Takes an item from `data` and renders it into the list.
@@ -160,6 +163,15 @@ Provides additional metadata like `index` if you need it, as well as a more gene
160163
| -------- | -------- |
161164
| function | Yes |
162165

166+
- `item` (Object): The item from `data` being rendered.
167+
- `index` (number): The index corresponding to this item in the `data` array.
168+
- `separators` (Object)
169+
- `highlight` (Function)
170+
- `unhighlight` (Function)
171+
- `updateProps` (Function)
172+
- `select` (enum('leading', 'trailing'))
173+
- `newProps` (Object)
174+
163175
Example usage:
164176

165177
```javascript
@@ -168,7 +180,7 @@ Example usage:
168180
<View style={[style.separator, highlighted && {marginLeft: 0}]} />
169181
)}
170182
data={[{title: 'Title Text', key: 'item1'}]}
171-
renderItem={({item, separators}) => (
183+
renderItem={({item, index, separators}) => (
172184
<TouchableHighlight
173185
onPress={() => this._onPress(item)}
174186
onShowUnderlay={separators.highlight}

0 commit comments

Comments
 (0)