-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample3.tsx
More file actions
48 lines (43 loc) · 1.35 KB
/
Copy pathExample3.tsx
File metadata and controls
48 lines (43 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { StyleSheet, View } from 'react-native';
import { observe } from 'react-native-observable-list';
import TrackableItem from './TrackableItem';
import { FlashList } from '@shopify/flash-list';
const ObservableFlatList = observe(FlashList);
const outerData = Array.from({ length: 300 }).map(() => ({}));
const innerData = Array.from({ length: 20 }).map(() => ({}));
const Example3 = () => {
return (
<ObservableFlatList
estimatedItemSize={110}
data={outerData}
ListHeaderComponent={<View style={styles.header} />}
getItemType={(_, index) => {
if (index % 10) return 'a';
return 'b';
}}
renderItem={({ index: outerIndex }) => {
if (outerIndex % 10) return <TrackableItem label={`${outerIndex}`} />;
return (
<ObservableFlatList
key={`inner-list-${outerIndex}`} // do not recycle !!
data={innerData}
estimatedItemSize={110}
horizontal
renderItem={({ index: innerIndex }) => {
return (
<TrackableItem
width={100}
label={`${outerIndex}-${innerIndex}`}
/>
);
}}
/>
);
}}
/>
);
};
const styles = StyleSheet.create({
header: { height: 200, backgroundColor: 'green' },
});
export default Example3;