Remove windowSize defaultProps

Summary:
Changelog:
[Internal][Changed] -Remove windowSize from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969589

fbshipit-source-id: da6215ee3876c8f186d59f91ef6fd94396366119
This commit is contained in:
Luna Wei 2021-03-17 12:46:06 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 3c5fa3b642
Коммит b3101457a6
5 изменённых файлов: 7 добавлений и 46 удалений

Просмотреть файл

@ -290,7 +290,7 @@ type OptionalProps = {|
* this number will reduce memory consumption and may improve performance, but will increase the * this number will reduce memory consumption and may improve performance, but will increase the
* chance that fast scrolling may reveal momentary blank areas of unrendered content. * chance that fast scrolling may reveal momentary blank areas of unrendered content.
*/ */
windowSize: number, windowSize?: ?number,
/** /**
* The legacy implementation is no longer supported. * The legacy implementation is no longer supported.
*/ */
@ -306,7 +306,6 @@ type Props = {|
type DefaultProps = {| type DefaultProps = {|
keyExtractor: (item: Item, index: number) => string, keyExtractor: (item: Item, index: number) => string,
updateCellsBatchingPeriod: number, updateCellsBatchingPeriod: number,
windowSize: number,
|}; |};
let _usedIndexForKey = false; let _usedIndexForKey = false;
@ -337,6 +336,10 @@ function scrollEventThrottleOrDefault(scrollEventThrottle: ?number) {
return scrollEventThrottle ?? 50; return scrollEventThrottle ?? 50;
} }
function windowSizeOrDefault(windowSize: ?number) {
return windowSize ?? 21;
}
/** /**
* Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist.html) * Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist.html)
* and [`<SectionList>`](https://reactnative.dev/docs/sectionlist.html) components, which are also better * and [`<SectionList>`](https://reactnative.dev/docs/sectionlist.html) components, which are also better
@ -593,7 +596,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
return String(index); return String(index);
}, },
updateCellsBatchingPeriod: 50, updateCellsBatchingPeriod: 50,
windowSize: 21, // multiples of length
}; };
_getCellKey(): string { _getCellKey(): string {
@ -691,9 +693,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' + 'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
'to support native onScroll events with useNativeDriver', 'to support native onScroll events with useNativeDriver',
); );
invariant( invariant(
props.windowSize > 0, windowSizeOrDefault(props.windowSize) > 0,
'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.', 'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.',
); );
@ -1753,7 +1754,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
this.props.data, this.props.data,
this.props.getItemCount, this.props.getItemCount,
maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch), maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch),
this.props.windowSize, windowSizeOrDefault(this.props.windowSize),
state, state,
this._getFrameMetricsApprox, this._getFrameMetricsApprox,
this._scrollMetrics, this._scrollMetrics,

Просмотреть файл

@ -50,7 +50,6 @@ exports[`FlatList renders all the bells and whistles 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<RCTRefreshControl /> <RCTRefreshControl />
<View> <View>
@ -140,7 +139,6 @@ exports[`FlatList renders empty list 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>
@ -164,7 +162,6 @@ exports[`FlatList renders null list 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>
@ -201,7 +198,6 @@ exports[`FlatList renders simple list (multiple columns) 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View> <View>
<View <View
@ -274,7 +270,6 @@ exports[`FlatList renders simple list 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View> <View>
<View <View
@ -336,7 +331,6 @@ exports[`FlatList renders simple list using ListItemComponent (multiple columns)
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View> <View>
<View <View
@ -409,7 +403,6 @@ exports[`FlatList renders simple list using ListItemComponent 1`] = `
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
viewabilityConfigCallbackPairs={Array []} viewabilityConfigCallbackPairs={Array []}
windowSize={21}
> >
<View> <View>
<View <View

Просмотреть файл

@ -35,7 +35,6 @@ exports[`SectionList rendering empty section headers is fine 1`] = `
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -94,7 +93,6 @@ exports[`SectionList renders a footer when there is no data 1`] = `
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -145,7 +143,6 @@ exports[`SectionList renders a footer when there is no data and no header 1`] =
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -238,7 +235,6 @@ exports[`SectionList renders all the bells and whistles 1`] = `
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<RCTRefreshControl /> <RCTRefreshControl />
<View> <View>
@ -412,7 +408,6 @@ exports[`SectionList renders empty list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>

Просмотреть файл

@ -63,7 +63,6 @@ exports[`VirtualizedList forwards correct stickyHeaderIndices when all in initia
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -205,7 +204,6 @@ exports[`VirtualizedList forwards correct stickyHeaderIndices when partially in
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -282,7 +280,6 @@ exports[`VirtualizedList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -315,7 +312,6 @@ exports[`VirtualizedList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View <View
onLayout={[Function]} onLayout={[Function]}
@ -365,7 +361,6 @@ exports[`VirtualizedList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -435,7 +430,6 @@ exports[`VirtualizedList handles separators correctly 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -512,7 +506,6 @@ exports[`VirtualizedList handles separators correctly 2`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -589,7 +582,6 @@ exports[`VirtualizedList handles separators correctly 3`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1047,7 +1039,6 @@ exports[`VirtualizedList renders all the bells and whistles 1`] = `
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<RCTRefreshControl /> <RCTRefreshControl />
<View> <View>
@ -1204,7 +1195,6 @@ exports[`VirtualizedList renders empty list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>
@ -1230,7 +1220,6 @@ exports[`VirtualizedList renders empty list with empty component 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1272,7 +1261,6 @@ exports[`VirtualizedList renders list with empty component 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1303,7 +1291,6 @@ exports[`VirtualizedList renders null list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>
@ -1338,7 +1325,6 @@ exports[`VirtualizedList renders simple list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1398,7 +1384,6 @@ exports[`VirtualizedList renders simple list using ListItemComponent 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1452,7 +1437,6 @@ exports[`VirtualizedList test getItem functionality where data is not an Array 1
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1491,7 +1475,6 @@ exports[`VirtualizedList warns if both renderItem or ListItemComponent are speci
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View

Просмотреть файл

@ -31,7 +31,6 @@ exports[`VirtualizedSectionList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -73,7 +72,6 @@ exports[`VirtualizedSectionList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View <View
onLayout={[Function]} onLayout={[Function]}
@ -136,7 +134,6 @@ exports[`VirtualizedSectionList handles nested lists 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -236,7 +233,6 @@ exports[`VirtualizedSectionList handles separators correctly 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -371,7 +367,6 @@ exports[`VirtualizedSectionList handles separators correctly 2`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -506,7 +501,6 @@ exports[`VirtualizedSectionList handles separators correctly 3`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -674,7 +668,6 @@ exports[`VirtualizedSectionList renders all the bells and whistles 1`] = `
] ]
} }
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<RCTRefreshControl /> <RCTRefreshControl />
<View> <View>
@ -871,7 +864,6 @@ exports[`VirtualizedSectionList renders empty list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View /> <View />
</RCTScrollView> </RCTScrollView>
@ -897,7 +889,6 @@ exports[`VirtualizedSectionList renders empty list with empty component 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -944,7 +935,6 @@ exports[`VirtualizedSectionList renders list with empty component 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View
@ -1001,7 +991,6 @@ exports[`VirtualizedSectionList renders simple list 1`] = `
scrollEventThrottle={50} scrollEventThrottle={50}
stickyHeaderIndices={Array []} stickyHeaderIndices={Array []}
updateCellsBatchingPeriod={50} updateCellsBatchingPeriod={50}
windowSize={21}
> >
<View> <View>
<View <View