@shopify/flash-list 2.0.2-rc.1 → 2.0.3
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/README.md +27 -97
- package/dist/AnimatedFlashList.js +2 -2
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -167
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +3 -595
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +2 -63
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js.map +1 -1
- package/dist/__tests__/LayoutCommitObserver.test.js +6 -4
- package/dist/__tests__/LayoutCommitObserver.test.js.map +1 -1
- package/dist/__tests__/RecyclerView.test.js +2 -2
- package/dist/__tests__/RecyclerView.test.js.map +1 -1
- package/dist/__tests__/ViewabilityHelper.test.js +3 -4
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +2 -1
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +2 -4
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +12 -24
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +2 -1
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/ErrorMessages.d.ts +16 -0
- package/dist/errors/ErrorMessages.d.ts.map +1 -0
- package/dist/errors/ErrorMessages.js +19 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +5 -0
- package/dist/errors/WarningMessages.d.ts.map +1 -0
- package/dist/errors/WarningMessages.js +9 -0
- package/dist/errors/WarningMessages.js.map +1 -0
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -29
- package/dist/index.js.map +1 -1
- package/dist/isNewArch.d.ts +2 -0
- package/dist/isNewArch.d.ts.map +1 -0
- package/dist/isNewArch.js +25 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +1 -22
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +1 -16
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +1 -22
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +1 -22
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +1 -15
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +1 -16
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +1 -23
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +1 -18
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +7 -1
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +9 -8
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts +1 -8
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +4 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js +2 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.d.ts +2 -2
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js +2 -4
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js.map +1 -1
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.d.ts +3 -3
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.js +16 -16
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jestSetup.js +0 -9
- package/package.json +2 -11
- package/src/AnimatedFlashList.ts +2 -2
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +3 -79
- package/src/__tests__/LayoutCommitObserver.test.tsx +7 -4
- package/src/__tests__/RecyclerView.test.tsx +2 -2
- package/src/__tests__/ViewabilityHelper.test.ts +13 -14
- package/src/benchmark/JSFPSMonitor.ts +3 -3
- package/src/benchmark/useBenchmark.ts +12 -40
- package/src/benchmark/useFlatListBenchmark.ts +3 -1
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +7 -0
- package/src/index.ts +7 -43
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +1 -25
- package/src/native/config/PlatformHelper.ios.ts +1 -24
- package/src/native/config/PlatformHelper.ts +1 -25
- package/src/native/config/PlatformHelper.web.ts +1 -30
- package/src/recyclerview/RecyclerView.tsx +7 -3
- package/src/recyclerview/RecyclerViewManager.ts +9 -18
- package/src/recyclerview/RecyclerViewProps.ts +1 -11
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +4 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +2 -1
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -9
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +18 -20
- package/RNFlashList.podspec +0 -37
- package/android/build.gradle +0 -89
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +0 -105
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +0 -158
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutViewManager.kt +0 -70
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +0 -29
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainer.java +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerImpl.kt +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerManager.kt +0 -34
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/FlashListPackage.kt +0 -19
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java +0 -47
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java +0 -21
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java +0 -32
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java +0 -16
- package/android/src/test/java/com/shopify/reactnative/flash_list/AutoLayoutShadowTest.kt +0 -147
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/Rect.kt +0 -61
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestCollection.kt +0 -6
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestDataModel.kt +0 -8
- package/android/src/test/resources/LayoutTestData.json +0 -788
- package/dist/GridLayoutProviderWithProps.d.ts +0 -42
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -114
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -51
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -252
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -22
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -37
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.d.ts +0 -2
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.js +0 -85
- package/dist/__tests__/ContentContainerUtils.test.js.map +0 -1
- package/dist/__tests__/FlashList.test.d.ts +0 -2
- package/dist/__tests__/FlashList.test.d.ts.map +0 -1
- package/dist/__tests__/FlashList.test.js +0 -902
- package/dist/__tests__/FlashList.test.js.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +0 -2
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +0 -143
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.d.ts +0 -2
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.js +0 -254
- package/dist/__tests__/MasonryFlashList.test.js.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.d.ts +0 -2
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.js +0 -33
- package/dist/__tests__/PlatformHelper.web.test.js.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.d.ts +0 -19
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.js +0 -44
- package/dist/__tests__/helpers/mountFlashList.js.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +0 -18
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.js +0 -49
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +0 -2
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.js +0 -179
- package/dist/__tests__/useBlankAreaTracker.test.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -34
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -66
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/enableNewCore.d.ts +0 -3
- package/dist/enableNewCore.d.ts.map +0 -1
- package/dist/enableNewCore.js +0 -25
- package/dist/enableNewCore.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -8
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -14
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -24
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -26
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -9
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -13
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -22
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -48
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -5
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -16
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -3
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -9
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -8
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -9
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -11
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -7
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -13
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.d.ts +0 -18
- package/dist/specs/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.js +0 -6
- package/dist/specs/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/specs/CellContainerNativeComponent.d.ts +0 -8
- package/dist/specs/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/specs/CellContainerNativeComponent.js +0 -6
- package/dist/specs/CellContainerNativeComponent.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -27
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -48
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/ios/RNFlashList.xcodeproj/project.pbxproj +0 -3
- package/ios/RNFlashList.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Sources/AutoLayoutView.swift +0 -294
- package/ios/Sources/AutoLayoutViewComponentView.h +0 -16
- package/ios/Sources/AutoLayoutViewComponentView.mm +0 -90
- package/ios/Sources/AutoLayoutViewManager.mm +0 -14
- package/ios/Sources/AutoLayoutViewManager.swift +0 -12
- package/ios/Sources/CellContainerComponentView.h +0 -18
- package/ios/Sources/CellContainerComponentView.mm +0 -62
- package/ios/Sources/CellContainerManager.mm +0 -8
- package/ios/Sources/CellContainerManager.swift +0 -12
- package/ios/Sources/FlatListPro-Bridging-Header.h +0 -11
- package/ios/Tests/AutoLayoutViewTests.swift +0 -113
- package/src/FlashList.tsx +0 -953
- package/src/GridLayoutProviderWithProps.ts +0 -180
- package/src/MasonryFlashList.tsx +0 -476
- package/src/PureComponentWrapper.tsx +0 -42
- package/src/__tests__/ContentContainerUtils.test.ts +0 -130
- package/src/__tests__/FlashList.test.tsx +0 -1001
- package/src/__tests__/GridLayoutProviderWithProps.test.ts +0 -179
- package/src/__tests__/MasonryFlashList.test.ts +0 -292
- package/src/__tests__/PlatformHelper.web.test.ts +0 -45
- package/src/__tests__/helpers/mountFlashList.tsx +0 -62
- package/src/__tests__/helpers/mountMasonryFlashList.tsx +0 -70
- package/src/__tests__/useBlankAreaTracker.test.tsx +0 -206
- package/src/benchmark/useBlankAreaTracker.ts +0 -117
- package/src/enableNewCore.ts +0 -24
- package/src/errors/CustomError.ts +0 -10
- package/src/errors/ExceptionList.ts +0 -28
- package/src/errors/Warnings.ts +0 -15
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -73
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -17
- package/src/native/cell-container/CellContainer.android.ts +0 -7
- package/src/native/cell-container/CellContainer.ios.ts +0 -7
- package/src/native/cell-container/CellContainer.tsx +0 -14
- package/src/native/cell-container/CellContainer.web.tsx +0 -9
- package/src/specs/AutoLayoutNativeComponent.ts +0 -24
- package/src/specs/CellContainerNativeComponent.ts +0 -9
- package/src/utils/ContentContainerUtils.ts +0 -92
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.d.ts +0 -0
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.js +0 -0
- /package/src/{viewability → recyclerview/viewability}/ViewToken.ts +0 -0
package/src/FlashListProps.ts
CHANGED
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
ViewStyle,
|
|
7
7
|
} from "react-native";
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
import ViewToken from "./viewability/ViewToken";
|
|
9
|
+
import ViewToken from "./recyclerview/viewability/ViewToken";
|
|
11
10
|
|
|
12
11
|
export interface ListRenderItemInfo<TItem> {
|
|
13
12
|
item: TItem;
|
|
@@ -40,18 +39,6 @@ export type ListRenderItem<TItem> = (
|
|
|
40
39
|
info: ListRenderItemInfo<TItem>
|
|
41
40
|
) => React.ReactElement | null;
|
|
42
41
|
|
|
43
|
-
export type ContentStyle = Pick<
|
|
44
|
-
ViewStyle,
|
|
45
|
-
| "backgroundColor"
|
|
46
|
-
| "paddingTop"
|
|
47
|
-
| "paddingLeft"
|
|
48
|
-
| "paddingRight"
|
|
49
|
-
| "paddingBottom"
|
|
50
|
-
| "padding"
|
|
51
|
-
| "paddingVertical"
|
|
52
|
-
| "paddingHorizontal"
|
|
53
|
-
>;
|
|
54
|
-
|
|
55
42
|
export interface ViewabilityConfigCallbackPair<TItem> {
|
|
56
43
|
viewabilityConfig: ViewabilityConfig;
|
|
57
44
|
onViewableItemsChanged:
|
|
@@ -89,14 +76,6 @@ export interface FlashListProps<TItem>
|
|
|
89
76
|
*/
|
|
90
77
|
data: ReadonlyArray<TItem> | null | undefined;
|
|
91
78
|
|
|
92
|
-
/**
|
|
93
|
-
* Average or median size for elements in the list. Doesn't have to be very accurate but a good estimate can improve performance.
|
|
94
|
-
* A quick look at `Element Inspector` can help you determine this. If you're confused between two values, the smaller value is a better choice.
|
|
95
|
-
* For vertical lists provide average height and for horizontal average width.
|
|
96
|
-
* Read more about it here: https://shopify.github.io/flash-list/docs/estimated-item-size
|
|
97
|
-
*/
|
|
98
|
-
estimatedItemSize?: number;
|
|
99
|
-
|
|
100
79
|
/**
|
|
101
80
|
* Each cell is rendered using this element.
|
|
102
81
|
* Can be a React Component Class, or a render function.
|
|
@@ -165,30 +144,11 @@ export interface FlashListProps<TItem>
|
|
|
165
144
|
| React.ComponentType<ScrollViewProps>
|
|
166
145
|
| React.FC<ScrollViewProps>;
|
|
167
146
|
|
|
168
|
-
/**
|
|
169
|
-
* You can use `contentContainerStyle` to apply padding that will be applied to the whole content itself.
|
|
170
|
-
* For example, you can apply this padding, so that all of your items have leading and trailing space.
|
|
171
|
-
*/
|
|
172
|
-
contentContainerStyle?: ContentStyle;
|
|
173
|
-
|
|
174
147
|
/**
|
|
175
148
|
* Draw distance for advanced rendering (in dp/px)
|
|
176
149
|
*/
|
|
177
150
|
drawDistance?: number;
|
|
178
151
|
|
|
179
|
-
/**
|
|
180
|
-
* Specifies how far the first item is drawn from start of the list window or, offset of the first item of the list (not the header).
|
|
181
|
-
* Needed if you're using initialScrollIndex prop. Before the initial draw the list cannot figure out the size of header or, any special margin/padding that might have been applied
|
|
182
|
-
* using header styles etc.
|
|
183
|
-
* If this isn't provided initialScrollIndex might not scroll to the provided index.
|
|
184
|
-
*/
|
|
185
|
-
estimatedFirstItemOffset?: number;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Visible height and width of the list. This is not the scroll content size.
|
|
189
|
-
*/
|
|
190
|
-
estimatedListSize?: { height: number; width: number };
|
|
191
|
-
|
|
192
152
|
/**
|
|
193
153
|
* A marker property for telling the list to re-render (since it implements PureComponent).
|
|
194
154
|
* If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop,
|
|
@@ -206,11 +166,6 @@ export interface FlashListProps<TItem>
|
|
|
206
166
|
*/
|
|
207
167
|
initialScrollIndex?: number | null | undefined;
|
|
208
168
|
|
|
209
|
-
/**
|
|
210
|
-
* Reverses the direction of scroll. Uses scale transforms of -1.
|
|
211
|
-
*/
|
|
212
|
-
inverted?: boolean | null | undefined;
|
|
213
|
-
|
|
214
169
|
/**
|
|
215
170
|
* Used to extract a unique key for a given item at the specified index.
|
|
216
171
|
* Key is used for optimizing performance. Defining `keyExtractor` is also necessary
|
|
@@ -225,18 +180,6 @@ export interface FlashListProps<TItem>
|
|
|
225
180
|
*/
|
|
226
181
|
numColumns?: number | undefined;
|
|
227
182
|
|
|
228
|
-
/**
|
|
229
|
-
* Computes blank space that is visible to the user during scroll or list load. If list doesn't have enough items to fill the screen even then this will be raised.
|
|
230
|
-
* Values reported: {
|
|
231
|
-
* offsetStart -> visible blank space on top of the screen (while going up). If value is greater than 0 then it's visible to user.
|
|
232
|
-
* offsetEnd -> visible blank space at the end of the screen (while going down). If value is greater than 0 then it's visible to user.
|
|
233
|
-
* blankArea -> max(offsetStart, offsetEnd) use this directly and look for values > 0
|
|
234
|
-
* }
|
|
235
|
-
* Please note that this event isn't synced with onScroll event but works with native onDraw/layoutSubviews. Events with values > 0 are blanks.
|
|
236
|
-
* This event is raised even when there is no visible blank with negative values for extensibility however, for most use cases check blankArea > 0 and use the value.
|
|
237
|
-
*/
|
|
238
|
-
onBlankArea?: BlankAreaEventHandler;
|
|
239
|
-
|
|
240
183
|
/**
|
|
241
184
|
* Called once when the scroll position gets within onEndReachedThreshold of the rendered content.
|
|
242
185
|
*/
|
|
@@ -292,11 +235,7 @@ export interface FlashListProps<TItem>
|
|
|
292
235
|
) => string | number | undefined;
|
|
293
236
|
|
|
294
237
|
/**
|
|
295
|
-
* This method can be used to
|
|
296
|
-
*
|
|
297
|
-
* Providing specific estimates is a good idea when you can calculate sizes reliably. FlashList will prefer this value over `estimatedItemSize` for that specific item.
|
|
298
|
-
* Precise estimates will also improve precision of `scrollToIndex` method and `initialScrollIndex` prop. If you have a `separator` below your items you can include its size in the estimate.
|
|
299
|
-
*
|
|
238
|
+
* This method can be used to change column span of an item.
|
|
300
239
|
* Changing item span is useful when you have grid layouts (numColumns > 1) and you want few items to be bigger than the rest.
|
|
301
240
|
*
|
|
302
241
|
* Modify the given layout. Do not return. FlashList will fallback to default values if this is ignored.
|
|
@@ -304,7 +243,7 @@ export interface FlashListProps<TItem>
|
|
|
304
243
|
* Performance: This method is called very frequently. Keep it fast.
|
|
305
244
|
*/
|
|
306
245
|
overrideItemLayout?: (
|
|
307
|
-
layout: { span?: number
|
|
246
|
+
layout: { span?: number },
|
|
308
247
|
item: TItem,
|
|
309
248
|
index: number,
|
|
310
249
|
maxColumns: number,
|
|
@@ -342,21 +281,6 @@ export interface FlashListProps<TItem>
|
|
|
342
281
|
| ViewabilityConfigCallbackPairs<TItem>
|
|
343
282
|
| undefined;
|
|
344
283
|
|
|
345
|
-
/**
|
|
346
|
-
* FlashList attempts to measure size of horizontal lists by drawing an extra list item in advance. This can sometimes cause issues when used with `initialScrollIndex` in lists
|
|
347
|
-
* with very little content. You might see some amount of over scroll. When set to true the list's rendered size needs to be deterministic (i.e., height and width greater than 0)
|
|
348
|
-
* as FlashList will skip rendering the extra item for measurement. Default value is `false`.
|
|
349
|
-
*/
|
|
350
|
-
disableHorizontalListHeightMeasurement?: boolean;
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* FlashList applies some fixes to layouts of its children which can conflict with custom `CellRendererComponent`
|
|
354
|
-
* implementations. You can disable this behavior by setting this to `true`.
|
|
355
|
-
* Recommendation: Set this to `true` while you apply special behavior to the `CellRendererComponent`. Once done set this to
|
|
356
|
-
* `false` again.
|
|
357
|
-
*/
|
|
358
|
-
disableAutoLayout?: boolean;
|
|
359
|
-
|
|
360
284
|
/**
|
|
361
285
|
* New arch only
|
|
362
286
|
* Maximum number of items in the recycle pool. These are the items that are cached in the recycle pool when they are scrolled off the screen.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@quilted/react-testing";
|
|
3
3
|
|
|
4
|
-
import { RecyclerView } from "../recyclerview/RecyclerView";
|
|
5
4
|
import { useFlashListContext } from "../recyclerview/RecyclerViewContextProvider";
|
|
6
5
|
import { LayoutCommitObserver } from "../recyclerview/LayoutCommitObserver";
|
|
6
|
+
import { FlashList } from "..";
|
|
7
7
|
|
|
8
8
|
describe("LayoutCommitObserver", () => {
|
|
9
9
|
it("should not alter ref captured by child", () => {
|
|
@@ -20,7 +20,7 @@ describe("LayoutCommitObserver", () => {
|
|
|
20
20
|
let commitLayoutEffectCount = 0;
|
|
21
21
|
|
|
22
22
|
const content = (
|
|
23
|
-
<
|
|
23
|
+
<FlashList
|
|
24
24
|
testID="parent"
|
|
25
25
|
data={[1]}
|
|
26
26
|
renderItem={() => (
|
|
@@ -29,7 +29,7 @@ describe("LayoutCommitObserver", () => {
|
|
|
29
29
|
commitLayoutEffectCount++;
|
|
30
30
|
}}
|
|
31
31
|
>
|
|
32
|
-
<
|
|
32
|
+
<FlashList
|
|
33
33
|
testID="child"
|
|
34
34
|
data={[1]}
|
|
35
35
|
renderItem={() => (
|
|
@@ -53,8 +53,11 @@ describe("LayoutCommitObserver", () => {
|
|
|
53
53
|
/>
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
render(content);
|
|
56
|
+
const renderResult = render(content);
|
|
57
57
|
|
|
58
58
|
expect(commitLayoutEffectCount).toBe(3);
|
|
59
|
+
|
|
60
|
+
// Force unmount to trigger cleanup of async operations
|
|
61
|
+
renderResult.unmount();
|
|
59
62
|
});
|
|
60
63
|
});
|
|
@@ -4,7 +4,7 @@ import "@quilted/react-testing/matchers";
|
|
|
4
4
|
import { render } from "@quilted/react-testing";
|
|
5
5
|
|
|
6
6
|
import { FlashListRef } from "../FlashListRef";
|
|
7
|
-
import {
|
|
7
|
+
import { FlashList } from "..";
|
|
8
8
|
|
|
9
9
|
// Mock measureLayout to return fixed dimensions
|
|
10
10
|
jest.mock("../recyclerview/utils/measureLayout", () => {
|
|
@@ -49,7 +49,7 @@ const renderRecyclerView = (args: {
|
|
|
49
49
|
data,
|
|
50
50
|
} = args;
|
|
51
51
|
return render(
|
|
52
|
-
<
|
|
52
|
+
<FlashList
|
|
53
53
|
ref={ref}
|
|
54
54
|
data={
|
|
55
55
|
data ?? [
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import ViewabilityHelper from "../recyclerview/viewability/ViewabilityHelper";
|
|
2
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
3
|
+
import {
|
|
4
|
+
RVDimension,
|
|
5
|
+
RVLayout,
|
|
6
|
+
} from "../recyclerview/layout-managers/LayoutManager";
|
|
6
7
|
|
|
7
8
|
describe("ViewabilityHelper", () => {
|
|
8
9
|
const viewableIndicesChanged = jest.fn();
|
|
@@ -61,7 +62,7 @@ describe("ViewabilityHelper", () => {
|
|
|
61
62
|
);
|
|
62
63
|
viewabilityHelper.possiblyViewableIndices = [0, 1, 2, 3];
|
|
63
64
|
const getLayout = (index: number) => {
|
|
64
|
-
return { x: index * 100, y: 0, height: 300, width: 100 } as
|
|
65
|
+
return { x: index * 100, y: 0, height: 300, width: 100 } as RVLayout;
|
|
65
66
|
};
|
|
66
67
|
updateViewableItems({ viewabilityHelper, horizontal: true, getLayout });
|
|
67
68
|
expect(viewableIndicesChanged).toHaveBeenCalledWith(
|
|
@@ -160,9 +161,9 @@ describe("ViewabilityHelper", () => {
|
|
|
160
161
|
it("reports items that only satisfy viewAreaCoveragePercentThreshold", () => {
|
|
161
162
|
const getLayout = (index: number) => {
|
|
162
163
|
if (index === 4) {
|
|
163
|
-
return { x: 0, y: index * 100, width: 100, height: 25 } as
|
|
164
|
+
return { x: 0, y: index * 100, width: 100, height: 25 } as RVLayout;
|
|
164
165
|
}
|
|
165
|
-
return { x: 0, y: index * 100, height: 100, width: 300 } as
|
|
166
|
+
return { x: 0, y: index * 100, height: 100, width: 300 } as RVLayout;
|
|
166
167
|
};
|
|
167
168
|
const viewabilityHelper = new ViewabilityHelper(
|
|
168
169
|
{ viewAreaCoveragePercentThreshold: 25 },
|
|
@@ -246,9 +247,7 @@ describe("ViewabilityHelper", () => {
|
|
|
246
247
|
viewableIndicesChanged
|
|
247
248
|
);
|
|
248
249
|
expect(() => updateViewableItems({ viewabilityHelper })).toThrow(
|
|
249
|
-
|
|
250
|
-
ExceptionList.multipleViewabilityThresholdTypesNotSupported
|
|
251
|
-
)
|
|
250
|
+
ErrorMessages.multipleViewabilityThresholdTypesNotSupported
|
|
252
251
|
);
|
|
253
252
|
});
|
|
254
253
|
|
|
@@ -263,8 +262,8 @@ describe("ViewabilityHelper", () => {
|
|
|
263
262
|
viewabilityHelper: ViewabilityHelper;
|
|
264
263
|
horizontal?: boolean;
|
|
265
264
|
scrollOffset?: number;
|
|
266
|
-
listSize?:
|
|
267
|
-
getLayout?: (index: number) =>
|
|
265
|
+
listSize?: RVDimension;
|
|
266
|
+
getLayout?: (index: number) => RVLayout | undefined;
|
|
268
267
|
runAllTimers?: boolean;
|
|
269
268
|
}) => {
|
|
270
269
|
viewabilityHelper.updateViewableItems(
|
|
@@ -273,7 +272,7 @@ describe("ViewabilityHelper", () => {
|
|
|
273
272
|
listSize ?? { height: 300, width: 300 },
|
|
274
273
|
getLayout ??
|
|
275
274
|
((index) => {
|
|
276
|
-
return { x: 0, y: index * 100, height: 100, width: 300 } as
|
|
275
|
+
return { x: 0, y: index * 100, height: 100, width: 300 } as RVLayout;
|
|
277
276
|
})
|
|
278
277
|
);
|
|
279
278
|
if (runAllTimers ?? true) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
2
|
+
|
|
1
3
|
import { roundToDecimalPlaces } from "./roundToDecimalPlaces";
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -44,9 +46,7 @@ export class JSFPSMonitor {
|
|
|
44
46
|
|
|
45
47
|
public startTracking() {
|
|
46
48
|
if (this.startTime !== 0) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
"This FPS Monitor has already been run, please create a new instance"
|
|
49
|
-
);
|
|
49
|
+
throw new Error(ErrorMessages.fpsMonitorAlreadyRunning);
|
|
50
50
|
}
|
|
51
51
|
this.startTime = Date.now();
|
|
52
52
|
this.timeWindow.startTime = Date.now();
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FlashListRef } from "../FlashListRef";
|
|
4
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
4
5
|
|
|
5
6
|
import { autoScroll, Cancellable } from "./AutoScrollHelper";
|
|
6
7
|
import { JSFPSMonitor, JSFPSResult } from "./JSFPSMonitor";
|
|
7
|
-
import { roundToDecimalPlaces } from "./roundToDecimalPlaces";
|
|
8
|
-
import {
|
|
9
|
-
BlankAreaTrackerResult,
|
|
10
|
-
useBlankAreaTracker,
|
|
11
|
-
} from "./useBlankAreaTracker";
|
|
12
8
|
|
|
13
9
|
export interface BenchmarkParams {
|
|
14
10
|
startDelayInMs?: number;
|
|
@@ -34,7 +30,6 @@ export interface BenchmarkResult {
|
|
|
34
30
|
js?: JSFPSResult;
|
|
35
31
|
interrupted: boolean;
|
|
36
32
|
suggestions: string[];
|
|
37
|
-
blankArea?: BlankAreaTrackerResult;
|
|
38
33
|
formattedString?: string;
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -45,21 +40,16 @@ export interface BenchmarkResult {
|
|
|
45
40
|
*/
|
|
46
41
|
|
|
47
42
|
export function useBenchmark(
|
|
48
|
-
flashListRef: React.RefObject<
|
|
43
|
+
flashListRef: React.RefObject<FlashListRef<any>>,
|
|
49
44
|
callback: (benchmarkResult: BenchmarkResult) => void,
|
|
50
45
|
params: BenchmarkParams = {}
|
|
51
46
|
) {
|
|
52
|
-
const [blankAreaResult, blankAreaTracker] = useBlankAreaTracker(
|
|
53
|
-
flashListRef,
|
|
54
|
-
undefined,
|
|
55
|
-
{ sumNegativeValues: params.sumNegativeBlankAreaValues, startDelayInMs: 0 }
|
|
56
|
-
);
|
|
57
47
|
useEffect(() => {
|
|
58
48
|
const cancellable = new Cancellable();
|
|
59
49
|
const suggestions: string[] = [];
|
|
60
50
|
if (flashListRef.current) {
|
|
61
51
|
if (!(Number(flashListRef.current.props.data?.length) > 0)) {
|
|
62
|
-
throw new Error(
|
|
52
|
+
throw new Error(ErrorMessages.dataEmptyCannotRunBenchmark);
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
55
|
const cancelTimeout = setTimeout(async () => {
|
|
@@ -81,7 +71,6 @@ export function useBenchmark(
|
|
|
81
71
|
computeSuggestions(flashListRef, suggestions);
|
|
82
72
|
const result: BenchmarkResult = generateResult(
|
|
83
73
|
jsProfilerResponse,
|
|
84
|
-
blankAreaResult,
|
|
85
74
|
suggestions,
|
|
86
75
|
cancellable
|
|
87
76
|
);
|
|
@@ -96,18 +85,12 @@ export function useBenchmark(
|
|
|
96
85
|
};
|
|
97
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
87
|
}, []);
|
|
99
|
-
return [blankAreaTracker];
|
|
100
88
|
}
|
|
101
89
|
|
|
102
90
|
export function getFormattedString(res: BenchmarkResult) {
|
|
103
91
|
return (
|
|
104
92
|
`Results:\n\n` +
|
|
105
93
|
`JS FPS: Avg: ${res.js?.averageFPS} | Min: ${res.js?.minFPS} | Max: ${res.js?.maxFPS}\n\n` +
|
|
106
|
-
`${
|
|
107
|
-
res.blankArea
|
|
108
|
-
? `Blank Area: Max: ${res.blankArea?.maxBlankArea} Cumulative: ${res.blankArea?.cumulativeBlankArea}\n\n`
|
|
109
|
-
: ``
|
|
110
|
-
}` +
|
|
111
94
|
`${
|
|
112
95
|
res.suggestions.length > 0
|
|
113
96
|
? `Suggestions:\n\n${res.suggestions
|
|
@@ -120,22 +103,11 @@ export function getFormattedString(res: BenchmarkResult) {
|
|
|
120
103
|
|
|
121
104
|
function generateResult(
|
|
122
105
|
jsProfilerResponse: JSFPSResult,
|
|
123
|
-
blankAreaResult: BlankAreaTrackerResult,
|
|
124
106
|
suggestions: string[],
|
|
125
107
|
cancellable: Cancellable
|
|
126
108
|
) {
|
|
127
109
|
return {
|
|
128
110
|
js: jsProfilerResponse,
|
|
129
|
-
blankArea:
|
|
130
|
-
blankAreaResult.maxBlankArea >= 0
|
|
131
|
-
? {
|
|
132
|
-
maxBlankArea: roundToDecimalPlaces(blankAreaResult.maxBlankArea, 0),
|
|
133
|
-
cumulativeBlankArea: roundToDecimalPlaces(
|
|
134
|
-
blankAreaResult.cumulativeBlankArea,
|
|
135
|
-
0
|
|
136
|
-
),
|
|
137
|
-
}
|
|
138
|
-
: undefined,
|
|
139
111
|
suggestions,
|
|
140
112
|
interrupted: cancellable.isCancelled(),
|
|
141
113
|
};
|
|
@@ -145,21 +117,21 @@ function generateResult(
|
|
|
145
117
|
* Scrolls to the end of the list and then back to the top
|
|
146
118
|
*/
|
|
147
119
|
async function runScrollBenchmark(
|
|
148
|
-
flashListRef: React.RefObject<
|
|
120
|
+
flashListRef: React.RefObject<FlashListRef<any> | null | undefined>,
|
|
149
121
|
cancellable: Cancellable,
|
|
150
122
|
scrollSpeedMultiplier: number
|
|
151
123
|
): Promise<void> {
|
|
152
124
|
if (flashListRef.current) {
|
|
153
125
|
const horizontal = flashListRef.current.props.horizontal;
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
const
|
|
126
|
+
const rv = flashListRef.current;
|
|
127
|
+
if (rv) {
|
|
128
|
+
const rvSize = rv.getWindowSize();
|
|
129
|
+
const rvContentSize = rv.getChildContainerDimensions();
|
|
158
130
|
|
|
159
131
|
const fromX = 0;
|
|
160
132
|
const fromY = 0;
|
|
161
|
-
const toX =
|
|
162
|
-
const toY =
|
|
133
|
+
const toX = rvContentSize.width - rvSize.width;
|
|
134
|
+
const toY = rvContentSize.height - rvSize.height;
|
|
163
135
|
|
|
164
136
|
const scrollNow = (x: number, y: number) => {
|
|
165
137
|
flashListRef.current?.scrollToOffset({
|
|
@@ -190,7 +162,7 @@ async function runScrollBenchmark(
|
|
|
190
162
|
}
|
|
191
163
|
}
|
|
192
164
|
function computeSuggestions(
|
|
193
|
-
flashListRef: React.RefObject<
|
|
165
|
+
flashListRef: React.RefObject<FlashListRef<any> | null | undefined>,
|
|
194
166
|
suggestions: string[]
|
|
195
167
|
) {
|
|
196
168
|
if (flashListRef.current) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { FlatList } from "react-native";
|
|
3
3
|
|
|
4
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
5
|
+
|
|
4
6
|
import { autoScroll, Cancellable } from "./AutoScrollHelper";
|
|
5
7
|
import { JSFPSMonitor } from "./JSFPSMonitor";
|
|
6
8
|
import {
|
|
@@ -27,7 +29,7 @@ export function useFlatListBenchmark(
|
|
|
27
29
|
const cancellable = new Cancellable();
|
|
28
30
|
if (flatListRef.current && flatListRef.current.props) {
|
|
29
31
|
if (!(Number(flatListRef.current.props.data?.length) > 0)) {
|
|
30
|
-
throw new Error(
|
|
32
|
+
throw new Error(ErrorMessages.dataEmptyCannotRunBenchmark);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
const cancelTimeout = setTimeout(async () => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const ErrorMessages = {
|
|
2
|
+
multipleViewabilityThresholdTypesNotSupported:
|
|
3
|
+
"You can set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold. Specifying both is not supported.",
|
|
4
|
+
flashListV2OnlySupportsNewArchitecture:
|
|
5
|
+
"FlashList v2 is only supported on new architecture",
|
|
6
|
+
layoutManagerNotInitializedLayoutInfo:
|
|
7
|
+
"LayoutManager is not initialized, layout info is unavailable",
|
|
8
|
+
layoutManagerNotInitializedChildContainer:
|
|
9
|
+
"LayoutManager is not initialized, child container layout is unavailable",
|
|
10
|
+
layoutManagerNotInitializedWindowSize:
|
|
11
|
+
"LayoutManager is not initialized, window size is unavailable",
|
|
12
|
+
horizontalPropCannotBeToggled:
|
|
13
|
+
"Horizontal prop cannot be toggled, you can use a key on FlashList to recreate it.",
|
|
14
|
+
layoutManagerNotInitializedVisibleIndices:
|
|
15
|
+
"LayoutManager is not initialized, visible indices are not unavailable",
|
|
16
|
+
masonryAndHorizontalIncompatible:
|
|
17
|
+
"Masonry and horizontal props are incompatible",
|
|
18
|
+
numColumnsAndHorizontalIncompatible:
|
|
19
|
+
"numColumns and horizontal props are incompatible",
|
|
20
|
+
indexOutOfBounds: "index out of bounds, not enough layouts",
|
|
21
|
+
fpsMonitorAlreadyRunning:
|
|
22
|
+
"This FPS Monitor has already been run, please create a new instance",
|
|
23
|
+
dataEmptyCannotRunBenchmark: "Data is empty, cannot run benchmark",
|
|
24
|
+
stickyHeadersNotSupportedForHorizontal:
|
|
25
|
+
"Sticky headers are not supported when list is horizontal",
|
|
26
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const WarningMessages = {
|
|
2
|
+
keyExtractorNotDefinedForAnimation:
|
|
3
|
+
"keyExtractor is not defined. This might cause the animations to not work as expected.",
|
|
4
|
+
exceededMaxRendersWithoutCommit:
|
|
5
|
+
"Exceeded max renders without commit. This might mean that you have duplicate keys in your keyExtractor output or your list is nested in a ScrollView causing a lot of items to render at once. " +
|
|
6
|
+
"If it's none of those and is causing a real issue or error, consider reporing this on FlashList Github",
|
|
7
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-named-default
|
|
2
|
-
import { default as OriginalFlashList } from "./FlashList";
|
|
3
|
-
import { isNewCoreEnabled } from "./enableNewCore";
|
|
4
|
-
import { RecyclerView } from "./recyclerview/RecyclerView";
|
|
5
|
-
|
|
6
1
|
// Keep this unmodified for TS type checking
|
|
7
|
-
|
|
2
|
+
import { isNewArch } from "./isNewArch";
|
|
3
|
+
import { ErrorMessages } from "./errors/ErrorMessages";
|
|
4
|
+
|
|
5
|
+
export { FlashList } from "./FlashList";
|
|
8
6
|
export { FlashListRef } from "./FlashListRef";
|
|
9
7
|
export {
|
|
10
8
|
FlashListProps,
|
|
11
|
-
ContentStyle,
|
|
12
9
|
ListRenderItem,
|
|
13
10
|
ListRenderItemInfo,
|
|
14
11
|
RenderTarget,
|
|
15
12
|
RenderTargetOptions,
|
|
16
13
|
} from "./FlashListProps";
|
|
17
14
|
export { default as AnimatedFlashList } from "./AnimatedFlashList";
|
|
18
|
-
export {
|
|
19
|
-
useOnNativeBlankAreaEvents,
|
|
20
|
-
BlankAreaEventHandler,
|
|
21
|
-
BlankAreaEvent,
|
|
22
|
-
} from "./native/auto-layout/AutoLayoutView";
|
|
23
15
|
export {
|
|
24
16
|
useBenchmark,
|
|
25
17
|
BenchmarkParams,
|
|
@@ -30,46 +22,18 @@ export {
|
|
|
30
22
|
useFlatListBenchmark,
|
|
31
23
|
FlatListBenchmarkParams,
|
|
32
24
|
} from "./benchmark/useFlatListBenchmark";
|
|
33
|
-
export {
|
|
34
|
-
useBlankAreaTracker,
|
|
35
|
-
BlankAreaTrackerResult,
|
|
36
|
-
BlankAreaTrackerConfig,
|
|
37
|
-
} from "./benchmark/useBlankAreaTracker";
|
|
38
|
-
export {
|
|
39
|
-
MasonryFlashList,
|
|
40
|
-
MasonryFlashListProps,
|
|
41
|
-
MasonryFlashListScrollEvent,
|
|
42
|
-
MasonryFlashListRef,
|
|
43
|
-
MasonryListItem,
|
|
44
|
-
MasonryListRenderItem,
|
|
45
|
-
MasonryListRenderItemInfo,
|
|
46
|
-
} from "./MasonryFlashList";
|
|
47
25
|
export { useLayoutState } from "./recyclerview/hooks/useLayoutState";
|
|
48
26
|
export { useRecyclingState } from "./recyclerview/hooks/useRecyclingState";
|
|
49
27
|
export { useMappingHelper } from "./recyclerview/hooks/useMappingHelper";
|
|
50
28
|
export { JSFPSMonitor, JSFPSResult } from "./benchmark/JSFPSMonitor";
|
|
51
29
|
export { autoScroll, Cancellable } from "./benchmark/AutoScrollHelper";
|
|
52
|
-
export { default as ViewToken } from "./viewability/ViewToken";
|
|
53
|
-
export { default as CellContainer } from "./native/cell-container/CellContainer";
|
|
54
|
-
export { RecyclerView } from "./recyclerview/RecyclerView";
|
|
55
|
-
export { RecyclerViewProps } from "./recyclerview/RecyclerViewProps";
|
|
30
|
+
export { default as ViewToken } from "./recyclerview/viewability/ViewToken";
|
|
56
31
|
export { useFlashListContext } from "./recyclerview/RecyclerViewContextProvider";
|
|
57
32
|
export {
|
|
58
33
|
LayoutCommitObserver,
|
|
59
34
|
LayoutCommitObserverProps,
|
|
60
35
|
} from "./recyclerview/LayoutCommitObserver";
|
|
61
36
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
typeof module !== "undefined" &&
|
|
66
|
-
module.exports &&
|
|
67
|
-
process?.env?.NODE_ENV !== "test"
|
|
68
|
-
) {
|
|
69
|
-
Object.defineProperty(module.exports, "FlashList", {
|
|
70
|
-
get() {
|
|
71
|
-
return isNewCoreEnabled() ? RecyclerView : OriginalFlashList;
|
|
72
|
-
},
|
|
73
|
-
configurable: true,
|
|
74
|
-
});
|
|
37
|
+
if (!isNewArch()) {
|
|
38
|
+
throw new Error(ErrorMessages.flashListV2OnlySupportsNewArchitecture);
|
|
75
39
|
}
|
package/src/isNewArch.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
let _isNewArch: boolean | undefined;
|
|
4
|
+
|
|
5
|
+
export function isNewArch(): boolean {
|
|
6
|
+
if (_isNewArch !== undefined) {
|
|
7
|
+
return _isNewArch;
|
|
8
|
+
} else {
|
|
9
|
+
try {
|
|
10
|
+
// Check for Fabric UI Manager
|
|
11
|
+
const hasFabricUIManager = Boolean(
|
|
12
|
+
(global as any)?.nativeFabricUIManager
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// Check for TurboModule system
|
|
16
|
+
const hasTurboModule = Boolean((global as any)?.__turboModuleProxy);
|
|
17
|
+
|
|
18
|
+
_isNewArch =
|
|
19
|
+
hasFabricUIManager || hasTurboModule || Platform.OS === "web";
|
|
20
|
+
} catch {
|
|
21
|
+
_isNewArch = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return _isNewArch;
|
|
25
|
+
}
|
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import { BaseItemAnimator } from "recyclerlistview";
|
|
2
|
-
|
|
3
1
|
const PlatformConfig = {
|
|
4
2
|
defaultDrawDistance: 250,
|
|
5
3
|
supportsOffsetCorrection: true,
|
|
6
4
|
trackAverageRenderTimeForOffsetProjection: true,
|
|
7
|
-
// Using rotate instead of scaleY on Android to avoid performance issues. Issue: https://github.com/Shopify/flash-list/issues/751
|
|
8
|
-
invertedTransformStyle: { transform: [{ rotate: "180deg" }] },
|
|
9
|
-
invertedTransformStyleHorizontal: { transform: [{ rotate: "180deg" }] },
|
|
10
|
-
};
|
|
11
|
-
const getCellContainerPlatformStyles = (
|
|
12
|
-
inverted: boolean,
|
|
13
|
-
parentProps: { x: number; y: number; isHorizontal?: boolean }
|
|
14
|
-
): { transform: string; WebkitTransform: string } | undefined => {
|
|
15
|
-
return undefined;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getItemAnimator = (): BaseItemAnimator | undefined => {
|
|
19
|
-
return undefined;
|
|
20
5
|
};
|
|
21
6
|
|
|
22
|
-
|
|
23
|
-
return undefined;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
PlatformConfig,
|
|
28
|
-
getCellContainerPlatformStyles,
|
|
29
|
-
getItemAnimator,
|
|
30
|
-
getFooterContainer,
|
|
31
|
-
};
|
|
7
|
+
export { PlatformConfig };
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import { BaseItemAnimator } from "recyclerlistview";
|
|
2
|
-
|
|
3
1
|
const PlatformConfig = {
|
|
4
2
|
defaultDrawDistance: 250,
|
|
5
3
|
supportsOffsetCorrection: true,
|
|
6
4
|
trackAverageRenderTimeForOffsetProjection: false,
|
|
7
|
-
invertedTransformStyle: { transform: [{ scaleY: -1 }] },
|
|
8
|
-
invertedTransformStyleHorizontal: { transform: [{ scaleX: -1 }] },
|
|
9
|
-
};
|
|
10
|
-
const getCellContainerPlatformStyles = (
|
|
11
|
-
inverted: boolean,
|
|
12
|
-
parentProps: { x: number; y: number; isHorizontal?: boolean }
|
|
13
|
-
): { transform: string; WebkitTransform: string } | undefined => {
|
|
14
|
-
return undefined;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const getItemAnimator = (): BaseItemAnimator | undefined => {
|
|
18
|
-
return undefined;
|
|
19
5
|
};
|
|
20
6
|
|
|
21
|
-
|
|
22
|
-
return undefined;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
PlatformConfig,
|
|
27
|
-
getCellContainerPlatformStyles,
|
|
28
|
-
getItemAnimator,
|
|
29
|
-
getFooterContainer,
|
|
30
|
-
};
|
|
7
|
+
export { PlatformConfig };
|