You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,58 @@ A collection of virtual list components, supporting the most handy features:
28
28
29
29
Virtualization massively improves memory consumption and performance of large lists by maintaining a finite render window of active items and replacing all items outside of the render window with appropriately sized blank space. The window adapts to scrolling behavior, and items are rendered incrementally with low-pri (after any running interactions) if they are far from the visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
30
30
31
+
## Caveats
32
+
33
+
Virtualized lists aren't appropriate for all situations. Here's some caveats:
34
+
35
+
- Internal state is not preserved when content scrolls out of the render window. Make sure all your data is captured in the item data or an external store like Rodux.
36
+
- This is a `PureComponent` which means that it will not re-render if `props` are shallow-equal. Make sure that everything your `renderItem` function depends on is passed as a prop (e.g. `extraData`) that is not `===` after updates, otherwise your UI may not update on changes. This includes the `data` prop and parent component state.
37
+
- In order to constrain memory and enable smooth scrolling, content is rendered asynchronously offscreen. This means it's possible to scroll faster than the fill rate and momentarily see blank content. This is a tradeoff that can be adjusted to suit the needs of each application.
38
+
- By default, the list looks for a `key` prop on each item and uses that for the React key. Alternatively, you can provide a custom `keyExtractor` prop.
39
+
40
+
## Example
41
+
42
+
```lua
43
+
localReact=require(...)
44
+
localVirtualizedList=require(...)
45
+
46
+
localView=VirtualizedList.View
47
+
localFlatList=VirtualizedList.FlatView
48
+
49
+
locale=React.createElement
50
+
51
+
localDATA= {
52
+
{
53
+
id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba',
54
+
title: 'First Item',
55
+
},
56
+
{
57
+
id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63',
58
+
title: 'Second Item',
59
+
},
60
+
{
61
+
id: '58694a0f-3da1-471f-bd96-145571e29d72',
62
+
title: 'Third Item',
63
+
},
64
+
}
65
+
66
+
localfunctionItem(props)
67
+
returne(View, {}, {
68
+
e("TextLabel", {
69
+
Size=UDim2.new(1, 0, 0, 40),
70
+
Text=props.title,
71
+
})
72
+
})
73
+
end
74
+
75
+
localfunctionApp()
76
+
returne(FlatList, {
77
+
data=DATA,
78
+
renderItem=Item,
79
+
})
80
+
end
81
+
```
82
+
31
83
## Documentation
32
84
33
85
More information on the provided list components can be found at:
0 commit comments