Skip to content

Commit 8bb19a7

Browse files
committed
Remove VirtualizedList disableVirtualization prop
1 parent 701de4e commit 8bb19a7

9 files changed

Lines changed: 30 additions & 630 deletions

File tree

packages/react-native/ReactNativeApi.d.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<42200de8ca10d30541e23b67547d9a13>>
7+
* @generated SignedSource<<338faddfc25b4c16d5055123589f59db>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -3407,7 +3407,6 @@ declare type OptionalSectionListProps<ItemT, SectionT = DefaultSectionT> = {
34073407
declare type OptionalVirtualizedListProps = {
34083408
CellRendererComponent?: React.ComponentType<CellRendererProps<Item>>
34093409
debug?: boolean
3410-
disableVirtualization?: boolean
34113410
extraData?: any
34123411
horizontal?: boolean
34133412
initialNumToRender?: number
@@ -5920,7 +5919,7 @@ export {
59205919
AlertOptions, // a0cdac0f
59215920
AlertType, // 5ab91217
59225921
AndroidKeyboardEvent, // e03becc8
5923-
Animated, // 1ac00401
5922+
Animated, // a3d1d649
59245923
AppConfig, // 35c0ca70
59255924
AppRegistry, // 7ef8e53a
59265925
AppState, // 12012be5
@@ -5970,9 +5969,9 @@ export {
59705969
EventSubscription, // b8d084aa
59715970
ExtendedExceptionData, // 5a6ccf5a
59725971
FilterFunction, // bf24c0e3
5973-
FlatList, // b5cfde24
5974-
FlatListInstance, // 8f76f3b2
5975-
FlatListProps, // 3725656d
5972+
FlatList, // cc8679e2
5973+
FlatListInstance, // 64354e60
5974+
FlatListProps, // 10085d10
59765975
FocusEvent, // 850f1517
59775976
FontVariant, // 7c7558bb
59785977
GestureResponderEvent, // 14d3e77a
@@ -6120,10 +6119,10 @@ export {
61206119
ScrollViewPropsIOS, // da991b9a
61216120
ScrollViewScrollToOptions, // 3313411e
61226121
SectionBase, // dca83594
6123-
SectionList, // 626263b4
6122+
SectionList, // 2c5dc428
61246123
SectionListData, // e0d79987
6125-
SectionListInstance, // 019cdaef
6126-
SectionListProps, // 4cb9dfa9
6124+
SectionListInstance, // f94c3498
6125+
SectionListProps, // 9bd7f8d1
61276126
SectionListRenderItem, // 466e3e87
61286127
SectionListRenderItemInfo, // d809238e
61296128
Separators, // 6a45f7e3
@@ -6197,10 +6196,10 @@ export {
61976196
VirtualViewMode, // 6be59722
61986197
VirtualizedList, // 68c7345e
61996198
VirtualizedListInstance, // 423ee7c0
6200-
VirtualizedListProps, // 29367911
6199+
VirtualizedListProps, // 14094746
62016200
VirtualizedSectionList, // 9fd9cd61
62026201
VirtualizedSectionListInstance, // 12b706d5
6203-
VirtualizedSectionListProps, // 6b9d9c05
6202+
VirtualizedSectionListProps, // bb4c282f
62046203
WrapperComponentProvider, // 4b8c7962
62056204
codegenNativeCommands, // 628a7c0a
62066205
codegenNativeComponent, // 32a1bca6

packages/rn-tester/js/examples/FlatList/FlatList-basic.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type State = {
6464
filterText: string,
6565
fixedHeight: boolean,
6666
logViewable: boolean,
67-
virtualized: boolean,
6867
empty: boolean,
6968
useFlatListItemComponent: boolean,
7069
fadingEdgeLength: number,
@@ -89,7 +88,6 @@ class FlatListExample extends React.PureComponent<Props, State> {
8988
filterText: '',
9089
fixedHeight: true,
9190
logViewable: false,
92-
virtualized: true,
9391
empty: false,
9492
useFlatListItemComponent: false,
9593
fadingEdgeLength: 0,
@@ -166,11 +164,6 @@ class FlatListExample extends React.PureComponent<Props, State> {
166164
/>
167165
</View>
168166
<View style={styles.options}>
169-
{renderSmallSwitchOption(
170-
'Virtualized',
171-
this.state.virtualized,
172-
this._setBooleanValue('virtualized'),
173-
)}
174167
{renderSmallSwitchOption(
175168
'Horizontal',
176169
this.state.horizontal,
@@ -260,7 +253,6 @@ class FlatListExample extends React.PureComponent<Props, State> {
260253
// $FlowFixMe[missing-empty-array-annot]
261254
data={this.state.empty ? [] : filteredData}
262255
debug={this.state.debug}
263-
disableVirtualization={!this.state.virtualized}
264256
getItemLayout={
265257
this.state.fixedHeight ? this._getItemLayout : undefined
266258
}

packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ component MultiColumnExample() {
3737
const [fixedHeight, setFixedHeight] = useState(true);
3838
const [logViewable, setLogViewable] = useState(false);
3939
const [numColumns, setNumColumns] = useState(2);
40-
const [virtualized, setVirtualized] = useState(true);
4140

4241
const _onChangeFilterText = (_filterText: string) => {
4342
setFilterText(_filterText);
@@ -48,9 +47,6 @@ component MultiColumnExample() {
4847

4948
const _setBooleanValue = (key: string) => (value: boolean) => {
5049
switch (key) {
51-
case 'virtualized':
52-
setVirtualized(value);
53-
break;
5450
case 'fixedHeight':
5551
setFixedHeight(value);
5652
break;
@@ -138,11 +134,6 @@ component MultiColumnExample() {
138134
/>
139135
</View>
140136
<View style={styles.row}>
141-
{renderSmallSwitchOption(
142-
'Virtualized',
143-
virtualized,
144-
_setBooleanValue('virtualized'),
145-
)}
146137
{renderSmallSwitchOption(
147138
'Fixed Height',
148139
fixedHeight,
@@ -168,7 +159,6 @@ component MultiColumnExample() {
168159
}
169160
refreshing={false}
170161
renderItem={_renderItemComponent}
171-
disableVirtualization={virtualized}
172162
onViewableItemsChanged={_onViewableItemsChanged}
173163
/>
174164
</RNTesterPage>

packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export component SectionList_scrollable() {
179179
{useNativeDriver: true},
180180
);
181181
const [filterText, setFilterText] = useState('');
182-
const [virtualized, setVirtualized] = useState(true);
183182
const [logViewable, setLogViewable] = useState(false);
184183
const [debug, setDebug] = useState(false);
185184
const [inverted, setInverted] = useState(false);
@@ -253,7 +252,6 @@ export component SectionList_scrollable() {
253252
value={filterText}
254253
/>
255254
<View style={styles.optionSection}>
256-
{renderSmallSwitchOption('Virtualized', virtualized, setVirtualized)}
257255
{renderSmallSwitchOption('Log Viewable', logViewable, setLogViewable)}
258256
{renderSmallSwitchOption('Debug', debug, setDebug)}
259257
{renderSmallSwitchOption('Inverted', inverted, setInverted)}
@@ -299,7 +297,6 @@ export component SectionList_scrollable() {
299297
accessibilityRole="list"
300298
debug={debug}
301299
inverted={inverted}
302-
disableVirtualization={!virtualized}
303300
onRefresh={() => Alert.alert('onRefresh: nothing to refresh :P')}
304301
onScroll={scrollSinkY}
305302
onViewableItemsChanged={onViewableItemsChanged}

packages/virtualized-lists/Lists/VirtualizedList.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
210210
*/
211211
debug?: boolean | undefined;
212212

213-
/**
214-
* DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
215-
* unmounts react instances that are outside of the render window. You should only need to disable
216-
* this for debugging purposes.
217-
*/
218-
disableVirtualization?: boolean | undefined;
219-
220213
/**
221214
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
222215
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the

packages/virtualized-lists/Lists/VirtualizedList.js

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,8 @@ class VirtualizedList extends StateSafePureComponent<
609609
pendingScrollUpdateCount: number,
610610
): {first: number, last: number} {
611611
const {data, getItemCount} = props;
612-
const onEndReachedThreshold = onEndReachedThresholdOrDefault(
613-
props.onEndReachedThreshold,
614-
);
615-
const {offset, visibleLength} = this._scrollMetrics;
612+
const {visibleLength} = this._scrollMetrics;
616613
const contentLength = this._listMetrics.getContentLength();
617-
const distanceFromEnd = contentLength - visibleLength - offset;
618614

619615
// Wait until the scroll view metrics have been set up. And until then,
620616
// we will trust the initialNumToRender suggestion
@@ -624,43 +620,27 @@ class VirtualizedList extends StateSafePureComponent<
624620
: cellsAroundViewport;
625621
}
626622

627-
let newCellsAroundViewport: {first: number, last: number};
628-
if (props.disableVirtualization) {
629-
const renderAhead =
630-
distanceFromEnd < onEndReachedThreshold * visibleLength
631-
? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
632-
: 0;
633-
634-
newCellsAroundViewport = {
635-
first: 0,
636-
last: Math.min(
637-
cellsAroundViewport.last + renderAhead,
638-
getItemCount(data) - 1,
639-
),
640-
};
641-
} else {
642-
// If we have a pending scroll update, we should not adjust the render window as it
643-
// might override the correct window.
644-
if (pendingScrollUpdateCount > 0) {
645-
return cellsAroundViewport.last >= getItemCount(data)
646-
? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
647-
: cellsAroundViewport;
648-
}
649-
650-
newCellsAroundViewport = computeWindowedRenderLimits(
651-
props,
652-
maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
653-
windowSizeOrDefault(props.windowSize),
654-
cellsAroundViewport,
655-
this._listMetrics,
656-
this._scrollMetrics,
657-
);
658-
invariant(
659-
newCellsAroundViewport.last < getItemCount(data),
660-
'computeWindowedRenderLimits() should return range in-bounds',
661-
);
623+
// If we have a pending scroll update, we should not adjust the render window as it
624+
// might override the correct window.
625+
if (pendingScrollUpdateCount > 0) {
626+
return cellsAroundViewport.last >= getItemCount(data)
627+
? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
628+
: cellsAroundViewport;
662629
}
663630

631+
const newCellsAroundViewport = computeWindowedRenderLimits(
632+
props,
633+
maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
634+
windowSizeOrDefault(props.windowSize),
635+
cellsAroundViewport,
636+
this._listMetrics,
637+
this._scrollMetrics,
638+
);
639+
invariant(
640+
newCellsAroundViewport.last < getItemCount(data),
641+
'computeWindowedRenderLimits() should return range in-bounds',
642+
);
643+
664644
if (this._nestedChildLists.size() > 0) {
665645
// If some cell in the new state has a child list in it, we should only render
666646
// up through that item, so that we give that list a chance to render.
@@ -1015,12 +995,6 @@ class VirtualizedList extends StateSafePureComponent<
1015995

1016996
for (const section of renderRegions) {
1017997
if (section.isSpacer) {
1018-
// Legacy behavior is to avoid spacers when virtualization is
1019-
// disabled (including head spacers on initial render).
1020-
if (this.props.disableVirtualization) {
1021-
continue;
1022-
}
1023-
1024998
// Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
1025999
// prevent the user for hyperscrolling into un-measured area because otherwise content will
10261000
// likely jump around as it renders in above the viewport.

packages/virtualized-lists/Lists/VirtualizedListProps.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ type OptionalVirtualizedListProps = {
7575
* implementation, but with a significant perf hit.
7676
*/
7777
debug?: ?boolean,
78-
/**
79-
* DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
80-
* unmounts react instances that are outside of the render window. You should only need to disable
81-
* this for debugging purposes. Defaults to false.
82-
*/
83-
disableVirtualization?: ?boolean,
8478
/**
8579
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
8680
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the

0 commit comments

Comments
 (0)