Skip to content

Commit 7818030

Browse files
committed
Remove VirtualizedList disableVirtualization prop
# Conflicts: # packages/react-native/ReactNativeApi.d.ts # Conflicts: # packages/react-native/ReactNativeApi.d.ts
1 parent 6b45e57 commit 7818030

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<<67eb674c33870c82986054f0cee48385>>
7+
* @generated SignedSource<<4994d05da642e8549ab401d357454b18>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -3413,7 +3413,6 @@ declare type OptionalSectionListProps<ItemT, SectionT = DefaultSectionT> = {
34133413
declare type OptionalVirtualizedListProps = {
34143414
CellRendererComponent?: React.ComponentType<CellRendererProps<Item>>
34153415
debug?: boolean
3416-
disableVirtualization?: boolean
34173416
extraData?: any
34183417
horizontal?: boolean
34193418
initialNumToRender?: number
@@ -5903,7 +5902,7 @@ export {
59035902
AlertOptions, // a0cdac0f
59045903
AlertType, // 5ab91217
59055904
AndroidKeyboardEvent, // e03becc8
5906-
Animated, // 91a7b171
5905+
Animated, // 65d52f22
59075906
AppConfig, // 35c0ca70
59085907
AppRegistry, // 7ef8e53a
59095908
AppState, // 12012be5
@@ -5953,9 +5952,9 @@ export {
59535952
EventSubscription, // b8d084aa
59545953
ExtendedExceptionData, // 5a6ccf5a
59555954
FilterFunction, // bf24c0e3
5956-
FlatList, // 0f2531c9
5957-
FlatListInstance, // f31d4744
5958-
FlatListProps, // b8b5adf2
5955+
FlatList, // eee316f3
5956+
FlatListInstance, // feed4943
5957+
FlatListProps, // 3742895c
59595958
FocusEvent, // 850f1517
59605959
FontVariant, // 7c7558bb
59615960
GestureResponderEvent, // 14d3e77a
@@ -6103,10 +6102,10 @@ export {
61036102
ScrollViewPropsIOS, // da991b9a
61046103
ScrollViewScrollToOptions, // 3313411e
61056104
SectionBase, // dca83594
6106-
SectionList, // f483c886
6105+
SectionList, // e667605d
61076106
SectionListData, // e0d79987
6108-
SectionListInstance, // 1b255509
6109-
SectionListProps, // e06b9868
6107+
SectionListInstance, // c08fb0c6
6108+
SectionListProps, // 4f77470e
61106109
SectionListRenderItem, // 466e3e87
61116110
SectionListRenderItemInfo, // d809238e
61126111
Separators, // 6a45f7e3
@@ -6180,10 +6179,10 @@ export {
61806179
VirtualViewMode, // 6be59722
61816180
VirtualizedList, // 68c7345e
61826181
VirtualizedListInstance, // 423ee7c0
6183-
VirtualizedListProps, // cc8bc4c9
6182+
VirtualizedListProps, // b44a5c80
61846183
VirtualizedSectionList, // 9fd9cd61
61856184
VirtualizedSectionListInstance, // 12b706d5
6186-
VirtualizedSectionListProps, // 12a58a4f
6185+
VirtualizedSectionListProps, // 400d5db8
61876186
WrapperComponentProvider, // 4b8c7962
61886187
codegenNativeCommands, // 628a7c0a
61896188
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)