Better implementation for getItemCount on FlatList (#26164)
Summary: Flatlist's `getItemCount` function is frequently called internally by VirtualizedList. As with other functions, we can remove unnecessary operations with the `numColumns` value. This makes it much more efficient. ## Changelog [Internal] [Changed] - Better implementation for getItemCount on FlatList Pull Request resolved: https://github.com/facebook/react-native/pull/26164 Test Plan: Not required Differential Revision: D16989335 Pulled By: sahrens fbshipit-source-id: b0075b2c2aeb9b9d7644c8bb18702a7cca8a4dce
This commit is contained in:
Родитель
b6333f79e1
Коммит
bb05176a4b
|
@ -560,7 +560,12 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|||
};
|
||||
|
||||
_getItemCount = (data: ?Array<ItemT>): number => {
|
||||
return data ? Math.ceil(data.length / this.props.numColumns) : 0;
|
||||
if (data) {
|
||||
const {numColumns} = this.props;
|
||||
return numColumns > 1 ? Math.ceil(data.length / numColumns) : data.length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
_keyExtractor = (items: ItemT | Array<ItemT>, index: number) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче