-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32843 from margelo/perunt/fix-last-spacer
Fix last spacer
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
diff --git a/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js b/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js | ||
index ef5a3f0..2590edd 100644 | ||
--- a/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js | ||
+++ b/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js | ||
@@ -125,19 +125,6 @@ function windowSizeOrDefault(windowSize: ?number) { | ||
return windowSize ?? 21; | ||
} | ||
|
||
-function findLastWhere<T>( | ||
- arr: $ReadOnlyArray<T>, | ||
- predicate: (element: T) => boolean, | ||
-): T | null { | ||
- for (let i = arr.length - 1; i >= 0; i--) { | ||
- if (predicate(arr[i])) { | ||
- return arr[i]; | ||
- } | ||
- } | ||
- | ||
- return null; | ||
-} | ||
- | ||
/** | ||
* Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist) | ||
* and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better | ||
@@ -1019,7 +1006,8 @@ class VirtualizedList extends StateSafePureComponent<Props, State> { | ||
const spacerKey = this._getSpacerKey(!horizontal); | ||
|
||
const renderRegions = this.state.renderMask.enumerateRegions(); | ||
- const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer); | ||
+ const lastRegion = renderRegions[renderRegions.length - 1]; | ||
+ const lastSpacer = lastRegion?.isSpacer ? lastRegion : null; | ||
|
||
for (const section of renderRegions) { | ||
if (section.isSpacer) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js | ||
index faeb323..68d740a 100644 | ||
--- a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js | ||
+++ b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js | ||
@@ -78,14 +78,6 @@ function scrollEventThrottleOrDefault(scrollEventThrottle) { | ||
function windowSizeOrDefault(windowSize) { | ||
return windowSize !== null && windowSize !== void 0 ? windowSize : 21; | ||
} | ||
-function findLastWhere(arr, predicate) { | ||
- for (var i = arr.length - 1; i >= 0; i--) { | ||
- if (predicate(arr[i])) { | ||
- return arr[i]; | ||
- } | ||
- } | ||
- return null; | ||
-} | ||
|
||
/** | ||
* Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist) | ||
@@ -1119,7 +1111,8 @@ class VirtualizedList extends StateSafePureComponent { | ||
_keylessItemComponentName = ''; | ||
var spacerKey = this._getSpacerKey(!horizontal); | ||
var renderRegions = this.state.renderMask.enumerateRegions(); | ||
- var lastSpacer = findLastWhere(renderRegions, r => r.isSpacer); | ||
+ var lastRegion = renderRegions[renderRegions.length - 1]; | ||
+ var lastSpacer = lastRegion?.isSpacer ? lastRegion : null; | ||
for (var _iterator = _createForOfIteratorHelperLoose(renderRegions), _step; !(_step = _iterator()).done;) { | ||
var section = _step.value; | ||
if (section.isSpacer) { |