@react-native/virtualized-lists 0.73.0 → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Lists/FillRateHelper.js +12 -20
- package/Lists/ListMetricsAggregator.js +385 -0
- package/Lists/StateSafePureComponent.js +2 -2
- package/Lists/ViewabilityHelper.js +15 -27
- package/Lists/VirtualizeUtils.js +11 -24
- package/Lists/VirtualizedList.d.ts +1 -1
- package/Lists/VirtualizedList.js +390 -337
- package/Lists/VirtualizedListCellRenderer.js +1 -1
- package/Lists/VirtualizedListContext.js +1 -3
- package/Lists/VirtualizedListProps.js +40 -9
- package/Lists/VirtualizedSectionList.js +5 -5
- package/README.md +21 -0
- package/package.json +15 -5
|
@@ -36,7 +36,7 @@ export type Props<ItemT> = {
|
|
|
36
36
|
onUnmount: (cellKey: string) => void,
|
|
37
37
|
onUpdateSeparators: (
|
|
38
38
|
cellKeys: Array<?string>,
|
|
39
|
-
props:
|
|
39
|
+
props: Partial<SeparatorProps<ItemT>>,
|
|
40
40
|
) => void,
|
|
41
41
|
prevCellKey: ?string,
|
|
42
42
|
renderItem?: ?RenderItemType<ItemT>,
|
|
@@ -31,9 +31,7 @@ type Context = $ReadOnly<{
|
|
|
31
31
|
cellKey: string,
|
|
32
32
|
ref: React.ElementRef<VirtualizedList>,
|
|
33
33
|
}) => void,
|
|
34
|
-
unregisterAsNestedChild: ({
|
|
35
|
-
ref: React.ElementRef<VirtualizedList>,
|
|
36
|
-
}) => void,
|
|
34
|
+
unregisterAsNestedChild: ({ref: React.ElementRef<VirtualizedList>}) => void,
|
|
37
35
|
}>;
|
|
38
36
|
|
|
39
37
|
export const VirtualizedListContext: React.Context<?Context> =
|
|
@@ -294,13 +294,44 @@ export type Props = {|
|
|
|
294
294
|
|};
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
*
|
|
297
|
+
* Default Props Helper Functions
|
|
298
|
+
* Use the following helper functions for default values
|
|
298
299
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
|
|
301
|
+
// horizontalOrDefault(this.props.horizontal)
|
|
302
|
+
export function horizontalOrDefault(horizontal: ?boolean): boolean {
|
|
303
|
+
return horizontal ?? false;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// initialNumToRenderOrDefault(this.props.initialNumToRender)
|
|
307
|
+
export function initialNumToRenderOrDefault(
|
|
308
|
+
initialNumToRender: ?number,
|
|
309
|
+
): number {
|
|
310
|
+
return initialNumToRender ?? 10;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
|
|
314
|
+
export function maxToRenderPerBatchOrDefault(
|
|
315
|
+
maxToRenderPerBatch: ?number,
|
|
316
|
+
): number {
|
|
317
|
+
return maxToRenderPerBatch ?? 10;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// onStartReachedThresholdOrDefault(this.props.onStartReachedThreshold)
|
|
321
|
+
export function onStartReachedThresholdOrDefault(
|
|
322
|
+
onStartReachedThreshold: ?number,
|
|
323
|
+
): number {
|
|
324
|
+
return onStartReachedThreshold ?? 2;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// onEndReachedThresholdOrDefault(this.props.onEndReachedThreshold)
|
|
328
|
+
export function onEndReachedThresholdOrDefault(
|
|
329
|
+
onEndReachedThreshold: ?number,
|
|
330
|
+
): number {
|
|
331
|
+
return onEndReachedThreshold ?? 2;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// windowSizeOrDefault(this.props.windowSize)
|
|
335
|
+
export function windowSizeOrDefault(windowSize: ?number): number {
|
|
336
|
+
return windowSize ?? 21;
|
|
337
|
+
}
|
|
@@ -138,11 +138,11 @@ class VirtualizedSectionList<
|
|
|
138
138
|
if (this._listRef == null) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
+
const listRef = this._listRef;
|
|
141
142
|
if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) {
|
|
142
|
-
const frame =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
143
|
+
const frame = listRef
|
|
144
|
+
.__getListMetrics()
|
|
145
|
+
.getCellMetricsApprox(index - params.itemIndex, listRef.props);
|
|
146
146
|
viewOffset += frame.length;
|
|
147
147
|
}
|
|
148
148
|
const toIndexParams = {
|
|
@@ -561,7 +561,7 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
|
|
|
561
561
|
},
|
|
562
562
|
updateProps: (
|
|
563
563
|
select: 'leading' | 'trailing',
|
|
564
|
-
newProps:
|
|
564
|
+
newProps: Partial<ItemWithSeparatorCommonProps>,
|
|
565
565
|
) => {
|
|
566
566
|
if (select === 'leading') {
|
|
567
567
|
if (LeadingSeparatorComponent != null) {
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @react-native/virtualized-lists
|
|
2
|
+
|
|
3
|
+
[![Version][version-badge]][package]
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @react-native/virtualized-lists
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
*Note: We're using `yarn` to install deps. Feel free to change commands to use `npm` 3+ and `npx` if you like*
|
|
12
|
+
|
|
13
|
+
[version-badge]: https://img.shields.io/npm/v/@react-native/virtualized-lists?style=flat-square
|
|
14
|
+
[package]: https://www.npmjs.com/package/@react-native/virtualized-lists
|
|
15
|
+
|
|
16
|
+
## Testing
|
|
17
|
+
|
|
18
|
+
To run the tests in this package, run the following commands from the React Native root folder:
|
|
19
|
+
|
|
20
|
+
1. `yarn` to install the dependencies. You just need to run this once
|
|
21
|
+
2. `yarn jest packages/virtualized-lists`.
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/virtualized-lists",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.1",
|
|
4
4
|
"description": "Virtualized lists for React Native.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
|
-
"url": "
|
|
8
|
+
"url": "https://github.com/facebook/react-native.git",
|
|
8
9
|
"directory": "packages/virtualized-lists"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
+
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/virtualized-lists#readme",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"lists",
|
|
14
|
+
"virtualized-lists",
|
|
15
|
+
"section-lists",
|
|
16
|
+
"react-native"
|
|
17
|
+
],
|
|
18
|
+
"bugs": "https://github.com/facebook/react-native/issues",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
11
22
|
"dependencies": {
|
|
12
23
|
"invariant": "^2.2.4",
|
|
13
24
|
"nullthrows": "^1.1.1"
|
|
@@ -16,7 +27,6 @@
|
|
|
16
27
|
"react-test-renderer": "18.2.0"
|
|
17
28
|
},
|
|
18
29
|
"peerDependencies": {
|
|
19
|
-
"react-native": "*"
|
|
20
|
-
"react-test-renderer": "18.2.0"
|
|
30
|
+
"react-native": "*"
|
|
21
31
|
}
|
|
22
32
|
}
|