Skip to content

Commit 873ad26

Browse files
committed
update readme
1 parent c9f9e72 commit 873ad26

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

README.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,40 @@ Cell Decorators are an easy way to add common hover animations. For example, wra
6666

6767
## Nesting DraggableFlatLists
6868

69-
Use an outer `NestableScrollContainer` paired with one or more inner `NestableDraggableFlatList` components to nest multiple separate `DraggableFlatList` components within a single scrollable parent. `NestableScrollContainer` extends a `ScrollView` from `react-native-gesture-handler`, and `NestableDraggableFlatList` shares the same API as a regular `DraggableFlatList`.
69+
It's possible to render multiple `DraggableFlatList` components within a single scrollable parent by wrapping one or more `NestableDraggableFlatList` components within an outer `NestableScrollContainer` component.
70+
71+
`NestableScrollContainer` extends the `ScrollView` from `react-native-gesture-handler`, and `NestableDraggableFlatList` extends `DraggableFlatList`, so all available props may be passed into both of them.
72+
73+
> Note: When using NestableDraggableFlatLists, all React Native warnings about nested list performance will be disabled.
7074
7175
```tsx
72-
<NestableScrollContainer>
73-
<Header text='List 1' />
74-
<NestableDraggableFlatList
75-
data={data1}
76-
renderItem={renderItem}
77-
keyExtractor={keyExtractor}
78-
onDragEnd={({ data }) => setData1(data)}
79-
/>
80-
<Header text='List 2' />
81-
<NestableDraggableFlatList
82-
data={data2}
83-
renderItem={renderItem}
84-
keyExtractor={keyExtractor}
85-
onDragEnd={({ data }) => setData2(data)}
86-
/>
87-
<Header text='List 3' />
88-
<NestableDraggableFlatList
89-
data={data3}
90-
renderItem={renderItem}
91-
keyExtractor={keyExtractor}
92-
onDragEnd={({ data }) => setData3(data)}
93-
/>
94-
</NestableScrollContainer>
76+
import { NestableScrollContainer, NestableDraggableFlatList } from "react-native-draggable-flatlist"
77+
78+
...
79+
80+
<NestableScrollContainer>
81+
<Header text='List 1' />
82+
<NestableDraggableFlatList
83+
data={data1}
84+
renderItem={renderItem}
85+
keyExtractor={keyExtractor}
86+
onDragEnd={({ data }) => setData1(data)}
87+
/>
88+
<Header text='List 2' />
89+
<NestableDraggableFlatList
90+
data={data2}
91+
renderItem={renderItem}
92+
keyExtractor={keyExtractor}
93+
onDragEnd={({ data }) => setData2(data)}
94+
/>
95+
<Header text='List 3' />
96+
<NestableDraggableFlatList
97+
data={data3}
98+
renderItem={renderItem}
99+
keyExtractor={keyExtractor}
100+
onDragEnd={({ data }) => setData3(data)}
101+
/>
102+
</NestableScrollContainer>
95103
```
96104

97105
![Nested DraggableFlatList demo](https://i.imgur.com/Kv0aj4l.gif)

0 commit comments

Comments
 (0)