@shopify/flash-list 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +67 -96
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +2 -2
- package/dist/AnimatedFlashList.d.ts +0 -1
- package/dist/AnimatedFlashList.d.ts.map +1 -1
- package/dist/AnimatedFlashList.js +3 -3
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +9 -0
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +22 -3
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +33 -13
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js.map +1 -1
- package/dist/FlashListRef.d.ts +305 -0
- package/dist/FlashListRef.d.ts.map +1 -0
- package/dist/FlashListRef.js +3 -0
- package/dist/FlashListRef.js.map +1 -0
- package/dist/GridLayoutProviderWithProps.js +1 -2
- package/dist/GridLayoutProviderWithProps.js.map +1 -1
- package/dist/MasonryFlashList.d.ts +2 -2
- package/dist/MasonryFlashList.d.ts.map +1 -1
- package/dist/MasonryFlashList.js.map +1 -1
- package/dist/PureComponentWrapper.js +1 -1
- package/dist/PureComponentWrapper.js.map +1 -1
- package/dist/__tests__/AverageWindow.test.js.map +1 -1
- package/dist/__tests__/ConsecutiveNumbers.test.d.ts +2 -0
- package/dist/__tests__/ConsecutiveNumbers.test.d.ts.map +1 -0
- package/dist/__tests__/ConsecutiveNumbers.test.js +224 -0
- package/dist/__tests__/ConsecutiveNumbers.test.js.map +1 -0
- package/dist/__tests__/FlashList.test.js.map +1 -1
- package/dist/__tests__/GridLayoutManager.test.d.ts +2 -0
- package/dist/__tests__/GridLayoutManager.test.d.ts.map +1 -0
- package/dist/__tests__/GridLayoutManager.test.js +69 -0
- package/dist/__tests__/GridLayoutManager.test.js.map +1 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +1 -1
- package/dist/__tests__/LayoutCommitObserver.test.d.ts +2 -0
- package/dist/__tests__/LayoutCommitObserver.test.d.ts.map +1 -0
- package/dist/__tests__/LayoutCommitObserver.test.js +35 -0
- package/dist/__tests__/LayoutCommitObserver.test.js.map +1 -0
- package/dist/__tests__/LinearLayoutManager.test.d.ts +2 -0
- package/dist/__tests__/LinearLayoutManager.test.d.ts.map +1 -0
- package/dist/__tests__/LinearLayoutManager.test.js +140 -0
- package/dist/__tests__/LinearLayoutManager.test.js.map +1 -0
- package/dist/__tests__/MasonryFlashList.test.js.map +1 -1
- package/dist/__tests__/MasonryLayoutManager.test.d.ts +2 -0
- package/dist/__tests__/MasonryLayoutManager.test.d.ts.map +1 -0
- package/dist/__tests__/MasonryLayoutManager.test.js +148 -0
- package/dist/__tests__/MasonryLayoutManager.test.js.map +1 -0
- package/dist/__tests__/RecyclerView.test.d.ts +2 -0
- package/dist/__tests__/RecyclerView.test.d.ts.map +1 -0
- package/dist/__tests__/RecyclerView.test.js +103 -0
- package/dist/__tests__/RecyclerView.test.js.map +1 -0
- package/dist/__tests__/RenderStackManager.test.d.ts +2 -0
- package/dist/__tests__/RenderStackManager.test.d.ts.map +1 -0
- package/dist/__tests__/RenderStackManager.test.js +485 -0
- package/dist/__tests__/RenderStackManager.test.js.map +1 -0
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
- package/dist/__tests__/findVisibleIndex.test.d.ts +2 -0
- package/dist/__tests__/findVisibleIndex.test.d.ts.map +1 -0
- package/dist/__tests__/findVisibleIndex.test.js +259 -0
- package/dist/__tests__/findVisibleIndex.test.js.map +1 -0
- package/dist/__tests__/helpers/createLayoutManager.d.ts +34 -0
- package/dist/__tests__/helpers/createLayoutManager.d.ts.map +1 -0
- package/dist/__tests__/helpers/createLayoutManager.js +110 -0
- package/dist/__tests__/helpers/createLayoutManager.js.map +1 -0
- package/dist/__tests__/helpers/mountFlashList.d.ts +2 -2
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +1 -1
- package/dist/__tests__/helpers/mountFlashList.js +2 -2
- package/dist/__tests__/helpers/mountFlashList.js.map +1 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +2 -2
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +1 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.js +2 -2
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +1 -1
- package/dist/__tests__/useBlankAreaTracker.test.js.map +1 -1
- package/dist/__tests__/useUnmountAwareCallbacks.test.d.ts +2 -0
- package/dist/__tests__/useUnmountAwareCallbacks.test.d.ts.map +1 -0
- package/dist/__tests__/useUnmountAwareCallbacks.test.js +185 -0
- package/dist/__tests__/useUnmountAwareCallbacks.test.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.js +2 -2
- package/dist/benchmark/AutoScrollHelper.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.js +1 -2
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
- package/dist/benchmark/useBenchmark.js +2 -28
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useBlankAreaTracker.js +1 -2
- package/dist/benchmark/useBlankAreaTracker.js.map +1 -1
- package/dist/benchmark/useDataMultiplier.js +1 -2
- package/dist/benchmark/useDataMultiplier.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts +0 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +9 -9
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/enableNewCore.d.ts.map +1 -1
- package/dist/enableNewCore.js +4 -4
- package/dist/enableNewCore.js.map +1 -1
- package/dist/errors/CustomError.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +1 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutView.js +1 -1
- package/dist/native/auto-layout/AutoLayoutView.js.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +1 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.d.ts +2 -0
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +2 -0
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +2 -0
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +2 -0
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +2 -0
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +2 -0
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +2 -0
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +3 -1
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
- package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
- package/dist/recyclerview/LayoutCommitObserver.js +62 -0
- package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
- package/dist/recyclerview/RecyclerView.d.ts +3 -2
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +133 -69
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +41 -7
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewContextProvider.js +6 -2
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts +31 -7
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +154 -117
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
- package/dist/recyclerview/RenderStackManager.d.ts +86 -0
- package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
- package/dist/recyclerview/RenderStackManager.js +343 -0
- package/dist/recyclerview/RenderStackManager.js.map +1 -0
- package/dist/recyclerview/ViewHolder.d.ts.map +1 -1
- package/dist/recyclerview/ViewHolder.js +8 -6
- package/dist/recyclerview/ViewHolder.js.map +1 -1
- package/dist/recyclerview/ViewHolderCollection.d.ts +10 -4
- package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -1
- package/dist/recyclerview/ViewHolderCollection.js +26 -10
- package/dist/recyclerview/ViewHolderCollection.js.map +1 -1
- package/dist/recyclerview/components/ScrollAnchor.d.ts +2 -1
- package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -1
- package/dist/recyclerview/components/ScrollAnchor.js +12 -9
- package/dist/recyclerview/components/ScrollAnchor.js.map +1 -1
- package/dist/recyclerview/components/StickyHeaders.d.ts +2 -2
- package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -1
- package/dist/recyclerview/components/StickyHeaders.js +44 -45
- package/dist/recyclerview/components/StickyHeaders.js.map +1 -1
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +1 -1
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -1
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js +2 -2
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -1
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +48 -2
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -1
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js +89 -19
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -1
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +11 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js +42 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.js +70 -0
- package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts +1 -3
- package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useBoundDetection.js +60 -28
- package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -1
- package/dist/recyclerview/hooks/useLayoutState.d.ts +3 -1
- package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useLayoutState.js +6 -5
- package/dist/recyclerview/hooks/useLayoutState.js.map +1 -1
- package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.js +19 -0
- package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts +2 -2
- package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useOnLoad.js +9 -10
- package/dist/recyclerview/hooks/useOnLoad.js.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +5 -49
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +343 -191
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +2 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewManager.js +11 -1
- package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/hooks/useRecyclingState.d.ts +4 -2
- package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclingState.js +3 -4
- package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -1
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts +1 -1
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useSecondaryProps.js +15 -12
- package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -1
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +63 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts +0 -1
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useUnmountFlag.js +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -1
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +18 -4
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/GridLayoutManager.js +61 -25
- package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts +36 -21
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js +96 -28
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +1 -2
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js +3 -3
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -1
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +9 -1
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +30 -16
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -1
- package/dist/recyclerview/utils/adjustOffsetForRTL.js +1 -2
- package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -1
- package/dist/recyclerview/utils/componentUtils.d.ts +1 -1
- package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -1
- package/dist/recyclerview/utils/componentUtils.js.map +1 -1
- package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -1
- package/dist/recyclerview/utils/findVisibleIndex.js +3 -5
- package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -1
- package/dist/recyclerview/utils/measureLayout.d.ts +24 -28
- package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -1
- package/dist/recyclerview/utils/measureLayout.js +36 -6
- package/dist/recyclerview/utils/measureLayout.js.map +1 -1
- package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.js +87 -0
- package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
- package/dist/specs/AutoLayoutNativeComponent.d.ts +1 -2
- package/dist/specs/AutoLayoutNativeComponent.d.ts.map +1 -1
- package/dist/specs/CellContainerNativeComponent.d.ts +0 -1
- package/dist/specs/CellContainerNativeComponent.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.js.map +1 -1
- package/dist/utils/ContentContainerUtils.d.ts.map +1 -1
- package/dist/utils/ContentContainerUtils.js.map +1 -1
- package/dist/viewability/ViewToken.d.ts +2 -2
- package/dist/viewability/ViewToken.d.ts.map +1 -1
- package/dist/viewability/ViewabilityHelper.js +1 -1
- package/dist/viewability/ViewabilityHelper.js.map +1 -1
- package/dist/viewability/ViewabilityManager.d.ts.map +1 -1
- package/dist/viewability/ViewabilityManager.js +11 -5
- package/dist/viewability/ViewabilityManager.js.map +1 -1
- package/jestSetup.js +30 -11
- package/package.json +4 -3
- package/src/AnimatedFlashList.ts +3 -2
- package/src/FlashList.tsx +25 -1
- package/src/FlashListProps.ts +42 -11
- package/src/FlashListRef.ts +320 -0
- package/src/MasonryFlashList.tsx +2 -2
- package/src/__tests__/ConsecutiveNumbers.test.ts +232 -0
- package/src/__tests__/GridLayoutManager.test.ts +113 -0
- package/src/__tests__/LayoutCommitObserver.test.tsx +60 -0
- package/src/__tests__/LinearLayoutManager.test.ts +227 -0
- package/src/__tests__/MasonryLayoutManager.test.ts +202 -0
- package/src/__tests__/RecyclerView.test.tsx +144 -0
- package/src/__tests__/RenderStackManager.test.ts +574 -0
- package/src/__tests__/findVisibleIndex.test.ts +369 -0
- package/src/__tests__/helpers/createLayoutManager.ts +141 -0
- package/src/__tests__/useUnmountAwareCallbacks.test.tsx +285 -0
- package/src/benchmark/useBenchmark.ts +0 -37
- package/src/benchmark/useFlatListBenchmark.ts +2 -2
- package/src/enableNewCore.ts +3 -1
- package/src/index.ts +14 -3
- package/src/native/config/PlatformHelper.android.ts +2 -0
- package/src/native/config/PlatformHelper.ios.ts +2 -0
- package/src/native/config/PlatformHelper.ts +2 -0
- package/src/native/config/PlatformHelper.web.ts +3 -1
- package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
- package/src/recyclerview/RecyclerView.tsx +178 -89
- package/src/recyclerview/RecyclerViewContextProvider.ts +53 -7
- package/src/recyclerview/RecyclerViewManager.ts +176 -97
- package/src/recyclerview/RecyclerViewProps.ts +2 -1
- package/src/recyclerview/RenderStackManager.ts +317 -0
- package/src/recyclerview/ViewHolder.tsx +13 -6
- package/src/recyclerview/ViewHolderCollection.tsx +45 -16
- package/src/recyclerview/components/ScrollAnchor.tsx +24 -11
- package/src/recyclerview/components/StickyHeaders.tsx +70 -58
- package/src/recyclerview/helpers/ConsecutiveNumbers.ts +2 -2
- package/src/recyclerview/helpers/EngagedIndicesTracker.ts +135 -25
- package/src/recyclerview/helpers/RenderTimeTracker.ts +42 -0
- package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
- package/src/recyclerview/hooks/useBoundDetection.ts +74 -25
- package/src/recyclerview/hooks/useLayoutState.ts +15 -6
- package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
- package/src/recyclerview/hooks/useOnLoad.ts +11 -10
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +380 -241
- package/src/recyclerview/hooks/useRecyclerViewManager.ts +13 -1
- package/src/recyclerview/hooks/useRecyclingState.ts +11 -7
- package/src/recyclerview/hooks/useSecondaryProps.tsx +12 -7
- package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
- package/src/recyclerview/hooks/useUnmountFlag.ts +1 -0
- package/src/recyclerview/layout-managers/GridLayoutManager.ts +68 -27
- package/src/recyclerview/layout-managers/LayoutManager.ts +116 -42
- package/src/recyclerview/layout-managers/LinearLayoutManager.ts +12 -8
- package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +34 -13
- package/src/recyclerview/utils/componentUtils.ts +1 -1
- package/src/recyclerview/utils/findVisibleIndex.ts +1 -2
- package/src/recyclerview/utils/measureLayout.ts +41 -2
- package/src/recyclerview/utils/measureLayout.web.ts +102 -0
- package/src/viewability/ViewToken.ts +2 -2
- package/src/viewability/ViewabilityHelper.ts +1 -1
- package/src/viewability/ViewabilityManager.ts +16 -9
- package/dist/recyclerview/RecycleKeyManager.d.ts +0 -82
- package/dist/recyclerview/RecycleKeyManager.d.ts.map +0 -1
- package/dist/recyclerview/RecycleKeyManager.js +0 -135
- package/dist/recyclerview/RecycleKeyManager.js.map +0 -1
- package/src/recyclerview/RecycleKeyManager.ts +0 -185
|
@@ -19,11 +19,14 @@ import {
|
|
|
19
19
|
NativeSyntheticEvent,
|
|
20
20
|
} from "react-native";
|
|
21
21
|
|
|
22
|
+
import { FlashListRef } from "../FlashListRef";
|
|
23
|
+
|
|
22
24
|
import { RVDimension } from "./layout-managers/LayoutManager";
|
|
23
25
|
import {
|
|
24
26
|
areDimensionsNotEqual,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
measureFirstChildLayout,
|
|
28
|
+
measureItemLayout,
|
|
29
|
+
measureParentSize,
|
|
27
30
|
} from "./utils/measureLayout";
|
|
28
31
|
import {
|
|
29
32
|
RecyclerViewContext,
|
|
@@ -46,6 +49,7 @@ import { useSecondaryProps } from "./hooks/useSecondaryProps";
|
|
|
46
49
|
import { StickyHeaders, StickyHeaderRef } from "./components/StickyHeaders";
|
|
47
50
|
import { ScrollAnchor, ScrollAnchorRef } from "./components/ScrollAnchor";
|
|
48
51
|
import { useRecyclerViewController } from "./hooks/useRecyclerViewController";
|
|
52
|
+
import { RenderTimeTracker } from "./helpers/RenderTimeTracker";
|
|
49
53
|
|
|
50
54
|
/**
|
|
51
55
|
* Main RecyclerView component that handles list rendering, scrolling, and item recycling.
|
|
@@ -53,7 +57,7 @@ import { useRecyclerViewController } from "./hooks/useRecyclerViewController";
|
|
|
53
57
|
*/
|
|
54
58
|
const RecyclerViewComponent = <T,>(
|
|
55
59
|
props: RecyclerViewProps<T>,
|
|
56
|
-
ref: React.Ref<
|
|
60
|
+
ref: React.Ref<FlashListRef<T>>
|
|
57
61
|
) => {
|
|
58
62
|
// Destructure props and initialize refs
|
|
59
63
|
const {
|
|
@@ -74,8 +78,6 @@ const RecyclerViewComponent = <T,>(
|
|
|
74
78
|
ListFooterComponentStyle,
|
|
75
79
|
ItemSeparatorComponent,
|
|
76
80
|
renderScrollComponent,
|
|
77
|
-
onScroll,
|
|
78
|
-
disableRecycling,
|
|
79
81
|
style,
|
|
80
82
|
stickyHeaderIndices,
|
|
81
83
|
maintainVisibleContentPosition,
|
|
@@ -83,10 +85,14 @@ const RecyclerViewComponent = <T,>(
|
|
|
83
85
|
...rest
|
|
84
86
|
} = props;
|
|
85
87
|
|
|
88
|
+
const [renderTimeTracker] = useState(() => new RenderTimeTracker());
|
|
89
|
+
|
|
90
|
+
renderTimeTracker.startTracking();
|
|
91
|
+
|
|
86
92
|
// Core refs for managing scroll view, internal view, and child container
|
|
87
93
|
const scrollViewRef = useRef<CompatScroller>(null);
|
|
88
94
|
const internalViewRef = useRef<CompatView>(null);
|
|
89
|
-
const
|
|
95
|
+
const firstChildViewRef = useRef<CompatView>(null);
|
|
90
96
|
const containerViewSizeRef = useRef<RVDimension | undefined>(undefined);
|
|
91
97
|
const pendingChildIds = useRef<Set<string>>(new Set()).current;
|
|
92
98
|
|
|
@@ -108,15 +114,19 @@ const RecyclerViewComponent = <T,>(
|
|
|
108
114
|
);
|
|
109
115
|
|
|
110
116
|
// Initialize core RecyclerView manager and content offset management
|
|
111
|
-
const { recyclerViewManager } =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const { recyclerViewManager, velocityTracker } =
|
|
118
|
+
useRecyclerViewManager(props);
|
|
119
|
+
const {
|
|
120
|
+
applyOffsetCorrection,
|
|
121
|
+
computeFirstVisibleIndexForOffsetCorrection,
|
|
122
|
+
applyInitialScrollIndex,
|
|
123
|
+
handlerMethods,
|
|
124
|
+
} = useRecyclerViewController(
|
|
125
|
+
recyclerViewManager,
|
|
126
|
+
ref,
|
|
127
|
+
scrollViewRef,
|
|
128
|
+
scrollAnchorRef
|
|
129
|
+
);
|
|
120
130
|
|
|
121
131
|
// Initialize view holder collection ref
|
|
122
132
|
const viewHolderCollectionRef = useRef<ViewHolderCollectionRef>(null);
|
|
@@ -125,40 +135,44 @@ const RecyclerViewComponent = <T,>(
|
|
|
125
135
|
useOnListLoad(recyclerViewManager, onLoad);
|
|
126
136
|
|
|
127
137
|
// Hook to detect when scrolling reaches list bounds
|
|
128
|
-
const { checkBounds } = useBoundDetection(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
scrollViewRef
|
|
132
|
-
);
|
|
138
|
+
const { checkBounds } = useBoundDetection(recyclerViewManager, scrollViewRef);
|
|
139
|
+
|
|
140
|
+
const isHorizontalRTL = I18nManager.isRTL && horizontal;
|
|
133
141
|
|
|
134
142
|
/**
|
|
135
143
|
* Initialize the RecyclerView by measuring and setting up the window size
|
|
136
144
|
* This effect runs when the component mounts or when layout changes
|
|
137
145
|
*/
|
|
138
146
|
useLayoutEffect(() => {
|
|
139
|
-
if (internalViewRef.current &&
|
|
147
|
+
if (internalViewRef.current && firstChildViewRef.current) {
|
|
140
148
|
// Measure the outer and inner container layouts
|
|
141
|
-
const outerViewLayout =
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
internalViewRef.current
|
|
145
|
-
undefined
|
|
149
|
+
const outerViewLayout = measureParentSize(internalViewRef.current);
|
|
150
|
+
const firstChildViewLayout = measureFirstChildLayout(
|
|
151
|
+
firstChildViewRef.current,
|
|
152
|
+
internalViewRef.current
|
|
146
153
|
);
|
|
147
154
|
|
|
148
155
|
containerViewSizeRef.current = outerViewLayout;
|
|
149
156
|
|
|
150
157
|
// Calculate offset of first item
|
|
151
158
|
const firstItemOffset = horizontal
|
|
152
|
-
?
|
|
153
|
-
:
|
|
159
|
+
? firstChildViewLayout.x - outerViewLayout.x
|
|
160
|
+
: firstChildViewLayout.y - outerViewLayout.y;
|
|
154
161
|
|
|
155
162
|
// Update the RecyclerView manager with window dimensions
|
|
156
163
|
recyclerViewManager.updateLayoutParams(
|
|
157
164
|
{
|
|
158
|
-
width: horizontal
|
|
159
|
-
|
|
165
|
+
width: horizontal
|
|
166
|
+
? outerViewLayout.width
|
|
167
|
+
: firstChildViewLayout.width,
|
|
168
|
+
height: horizontal
|
|
169
|
+
? firstChildViewLayout.height
|
|
170
|
+
: outerViewLayout.height,
|
|
160
171
|
},
|
|
161
|
-
|
|
172
|
+
isHorizontalRTL && recyclerViewManager.hasLayout()
|
|
173
|
+
? firstItemOffset -
|
|
174
|
+
recyclerViewManager.getChildContainerDimensions().width
|
|
175
|
+
: firstItemOffset
|
|
162
176
|
);
|
|
163
177
|
}
|
|
164
178
|
});
|
|
@@ -167,18 +181,19 @@ const RecyclerViewComponent = <T,>(
|
|
|
167
181
|
* Effect to handle layout updates for list items
|
|
168
182
|
* This ensures proper positioning and recycling of items
|
|
169
183
|
*/
|
|
184
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
185
|
useLayoutEffect(() => {
|
|
171
186
|
if (pendingChildIds.size > 0) {
|
|
172
187
|
return;
|
|
173
188
|
}
|
|
174
189
|
const layoutInfo = Array.from(refHolder, ([index, viewHolderRef]) => {
|
|
175
|
-
const layout =
|
|
190
|
+
const layout = measureItemLayout(
|
|
176
191
|
viewHolderRef.current!,
|
|
177
|
-
recyclerViewManager.
|
|
192
|
+
recyclerViewManager.tryGetLayout(index)
|
|
178
193
|
);
|
|
179
194
|
|
|
180
|
-
//comapre height with stored layout
|
|
181
|
-
//const storedLayout = recyclerViewManager.getLayout(index);
|
|
195
|
+
// comapre height with stored layout
|
|
196
|
+
// const storedLayout = recyclerViewManager.getLayout(index);
|
|
182
197
|
// if (
|
|
183
198
|
// storedLayout.height !== layout.height &&
|
|
184
199
|
// storedLayout.isHeightMeasured
|
|
@@ -199,10 +214,8 @@ const RecyclerViewComponent = <T,>(
|
|
|
199
214
|
// Trigger re-render if layout modifications were made
|
|
200
215
|
setRenderId((prev) => prev + 1);
|
|
201
216
|
} else {
|
|
202
|
-
//console.log("commitLayout");
|
|
203
|
-
// TODO: reduce perf impact of commitLayout
|
|
204
217
|
viewHolderCollectionRef.current?.commitLayout();
|
|
205
|
-
|
|
218
|
+
applyOffsetCorrection();
|
|
206
219
|
}
|
|
207
220
|
});
|
|
208
221
|
|
|
@@ -211,30 +224,45 @@ const RecyclerViewComponent = <T,>(
|
|
|
211
224
|
*/
|
|
212
225
|
const onScrollHandler = useCallback(
|
|
213
226
|
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
214
|
-
|
|
227
|
+
if (recyclerViewManager.ignoreScrollEvents) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
215
231
|
let scrollOffset = horizontal
|
|
216
232
|
? event.nativeEvent.contentOffset.x
|
|
217
233
|
: event.nativeEvent.contentOffset.y;
|
|
218
234
|
|
|
219
235
|
// Handle RTL (Right-to-Left) layout adjustments
|
|
220
|
-
if (
|
|
236
|
+
if (isHorizontalRTL) {
|
|
221
237
|
scrollOffset = adjustOffsetForRTL(
|
|
222
238
|
scrollOffset,
|
|
223
239
|
event.nativeEvent.contentSize.width,
|
|
224
240
|
event.nativeEvent.layoutMeasurement.width
|
|
225
241
|
);
|
|
226
|
-
if (velocity) {
|
|
227
|
-
velocity = {
|
|
228
|
-
x: -velocity.x,
|
|
229
|
-
y: velocity.y,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
242
|
}
|
|
233
243
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
velocityTracker.computeVelocity(
|
|
245
|
+
scrollOffset,
|
|
246
|
+
recyclerViewManager.getAbsoluteLastScrollOffset(),
|
|
247
|
+
Boolean(horizontal),
|
|
248
|
+
(velocity, isMomentumEnd) => {
|
|
249
|
+
if (recyclerViewManager.ignoreScrollEvents) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (isMomentumEnd) {
|
|
254
|
+
computeFirstVisibleIndexForOffsetCorrection();
|
|
255
|
+
if (!recyclerViewManager.isOffsetProjectionEnabled) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
recyclerViewManager.resetVelocityCompute();
|
|
259
|
+
}
|
|
260
|
+
// Update scroll position and trigger re-render if needed
|
|
261
|
+
if (recyclerViewManager.updateScrollOffset(scrollOffset, velocity)) {
|
|
262
|
+
setRenderId((prev) => prev + 1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
238
266
|
|
|
239
267
|
// Update sticky headers and check bounds
|
|
240
268
|
stickyHeaderRef.current?.reportScrollEvent(event.nativeEvent);
|
|
@@ -245,22 +273,41 @@ const RecyclerViewComponent = <T,>(
|
|
|
245
273
|
recyclerViewManager.computeItemViewability();
|
|
246
274
|
|
|
247
275
|
// Call user-provided onScroll handler
|
|
248
|
-
onScroll?.(event);
|
|
276
|
+
recyclerViewManager.props.onScroll?.(event);
|
|
249
277
|
},
|
|
250
|
-
[
|
|
278
|
+
[
|
|
279
|
+
checkBounds,
|
|
280
|
+
computeFirstVisibleIndexForOffsetCorrection,
|
|
281
|
+
horizontal,
|
|
282
|
+
isHorizontalRTL,
|
|
283
|
+
recyclerViewManager,
|
|
284
|
+
velocityTracker,
|
|
285
|
+
]
|
|
251
286
|
);
|
|
252
287
|
|
|
288
|
+
const parentRecyclerViewContext = useRecyclerViewContext();
|
|
289
|
+
const recyclerViewId = useId();
|
|
290
|
+
|
|
253
291
|
// Create context for child components
|
|
254
|
-
const recyclerViewContext: RecyclerViewContext = useMemo(() => {
|
|
292
|
+
const recyclerViewContext: RecyclerViewContext<T> = useMemo(() => {
|
|
255
293
|
return {
|
|
256
294
|
layout: () => {
|
|
257
295
|
setLayoutTreeId((prev) => prev + 1);
|
|
258
296
|
},
|
|
259
297
|
getRef: () => {
|
|
260
|
-
|
|
298
|
+
if (recyclerViewManager.isDisposed) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
return handlerMethods;
|
|
302
|
+
},
|
|
303
|
+
getParentRef: () => {
|
|
304
|
+
return parentRecyclerViewContext?.getRef() ?? null;
|
|
305
|
+
},
|
|
306
|
+
getParentScrollViewRef: () => {
|
|
307
|
+
return parentRecyclerViewContext?.getScrollViewRef() ?? null;
|
|
261
308
|
},
|
|
262
309
|
getScrollViewRef: () => {
|
|
263
|
-
return scrollViewRef;
|
|
310
|
+
return scrollViewRef.current;
|
|
264
311
|
},
|
|
265
312
|
markChildLayoutAsPending: (id: string) => {
|
|
266
313
|
pendingChildIds.add(id);
|
|
@@ -272,10 +319,13 @@ const RecyclerViewComponent = <T,>(
|
|
|
272
319
|
}
|
|
273
320
|
},
|
|
274
321
|
};
|
|
275
|
-
}, [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
322
|
+
}, [
|
|
323
|
+
handlerMethods,
|
|
324
|
+
parentRecyclerViewContext,
|
|
325
|
+
pendingChildIds,
|
|
326
|
+
recyclerViewManager.isDisposed,
|
|
327
|
+
setLayoutTreeId,
|
|
328
|
+
]);
|
|
279
329
|
|
|
280
330
|
/**
|
|
281
331
|
* Validates that item dimensions match the expected layout
|
|
@@ -307,7 +357,7 @@ const RecyclerViewComponent = <T,>(
|
|
|
307
357
|
recyclerViewContext.layout();
|
|
308
358
|
}
|
|
309
359
|
},
|
|
310
|
-
[recyclerViewManager]
|
|
360
|
+
[recyclerViewContext, recyclerViewManager]
|
|
311
361
|
);
|
|
312
362
|
|
|
313
363
|
// Get secondary props and components
|
|
@@ -347,7 +397,14 @@ const RecyclerViewComponent = <T,>(
|
|
|
347
397
|
);
|
|
348
398
|
}
|
|
349
399
|
return null;
|
|
350
|
-
}, [
|
|
400
|
+
}, [
|
|
401
|
+
data,
|
|
402
|
+
stickyHeaderIndices,
|
|
403
|
+
renderItem,
|
|
404
|
+
scrollY,
|
|
405
|
+
recyclerViewManager,
|
|
406
|
+
extraData,
|
|
407
|
+
]);
|
|
351
408
|
|
|
352
409
|
// Set up scroll event handling with animation support for sticky headers
|
|
353
410
|
const animatedEvent = useMemo(() => {
|
|
@@ -358,31 +415,24 @@ const RecyclerViewComponent = <T,>(
|
|
|
358
415
|
);
|
|
359
416
|
}
|
|
360
417
|
return onScrollHandler;
|
|
361
|
-
}, [onScrollHandler, stickyHeaders]);
|
|
418
|
+
}, [onScrollHandler, scrollY, stickyHeaders]);
|
|
419
|
+
|
|
420
|
+
const shouldMaintainVisibleContentPosition =
|
|
421
|
+
recyclerViewManager.shouldMaintainVisibleContentPosition();
|
|
362
422
|
|
|
363
423
|
const maintainVisibleContentPositionInternal = useMemo(() => {
|
|
364
|
-
if (
|
|
365
|
-
return undefined;
|
|
366
|
-
} else {
|
|
424
|
+
if (shouldMaintainVisibleContentPosition) {
|
|
367
425
|
return {
|
|
368
426
|
...maintainVisibleContentPosition,
|
|
369
427
|
minIndexForVisible: 0,
|
|
370
428
|
};
|
|
371
429
|
}
|
|
372
|
-
|
|
430
|
+
return undefined;
|
|
431
|
+
}, [maintainVisibleContentPosition, shouldMaintainVisibleContentPosition]);
|
|
373
432
|
|
|
374
433
|
const shouldRenderFromBottom =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
// Calculate minimum height adjustment for bottom rendering
|
|
378
|
-
const adjustmentMinHeight = recyclerViewManager.hasLayout()
|
|
379
|
-
? Math.max(
|
|
380
|
-
0,
|
|
381
|
-
recyclerViewManager.getWindowSize().height -
|
|
382
|
-
recyclerViewManager.getChildContainerDimensions().height -
|
|
383
|
-
recyclerViewManager.firstItemOffset
|
|
384
|
-
)
|
|
385
|
-
: 0;
|
|
434
|
+
recyclerViewManager.getDataLength() > 0 &&
|
|
435
|
+
(maintainVisibleContentPosition?.startRenderingFromBottom ?? false);
|
|
386
436
|
|
|
387
437
|
// Create view for measuring bounded size
|
|
388
438
|
const viewToMeasureBoundedSize = useMemo(() => {
|
|
@@ -391,20 +441,35 @@ const RecyclerViewComponent = <T,>(
|
|
|
391
441
|
style={{
|
|
392
442
|
height: horizontal ? undefined : 0,
|
|
393
443
|
width: horizontal ? 0 : undefined,
|
|
394
|
-
minHeight: shouldRenderFromBottom ? adjustmentMinHeight : undefined,
|
|
395
444
|
}}
|
|
396
|
-
ref={
|
|
445
|
+
ref={firstChildViewRef}
|
|
397
446
|
/>
|
|
398
447
|
);
|
|
399
|
-
}, [horizontal
|
|
448
|
+
}, [horizontal]);
|
|
400
449
|
|
|
401
|
-
|
|
450
|
+
const scrollAnchor = useMemo(() => {
|
|
451
|
+
if (shouldMaintainVisibleContentPosition) {
|
|
452
|
+
return (
|
|
453
|
+
<ScrollAnchor
|
|
454
|
+
horizontal={Boolean(horizontal)}
|
|
455
|
+
scrollAnchorRef={scrollAnchorRef}
|
|
456
|
+
/>
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
return null;
|
|
460
|
+
}, [horizontal, shouldMaintainVisibleContentPosition]);
|
|
461
|
+
|
|
462
|
+
// console.log("render", recyclerViewManager.getRenderStack());
|
|
402
463
|
|
|
403
464
|
// Render the main RecyclerView structure
|
|
404
465
|
return (
|
|
405
466
|
<RecyclerViewContextProvider value={recyclerViewContext}>
|
|
406
467
|
<CompatView
|
|
407
|
-
style={{
|
|
468
|
+
style={{
|
|
469
|
+
flex: horizontal ? undefined : 1,
|
|
470
|
+
overflow: "hidden",
|
|
471
|
+
...style,
|
|
472
|
+
}}
|
|
408
473
|
ref={internalViewRef}
|
|
409
474
|
collapsable={false}
|
|
410
475
|
onLayout={(event) => {
|
|
@@ -433,7 +498,6 @@ const RecyclerViewComponent = <T,>(
|
|
|
433
498
|
horizontal={horizontal}
|
|
434
499
|
ref={scrollViewRef}
|
|
435
500
|
onScroll={animatedEvent}
|
|
436
|
-
// TODO: evaluate perf
|
|
437
501
|
maintainVisibleContentPosition={
|
|
438
502
|
maintainVisibleContentPositionInternal
|
|
439
503
|
}
|
|
@@ -441,11 +505,10 @@ const RecyclerViewComponent = <T,>(
|
|
|
441
505
|
{...overrideProps}
|
|
442
506
|
>
|
|
443
507
|
{/* Scroll anchor for maintaining content position */}
|
|
444
|
-
{
|
|
445
|
-
|
|
446
|
-
)}
|
|
508
|
+
{scrollAnchor}
|
|
509
|
+
{isHorizontalRTL && viewToMeasureBoundedSize}
|
|
447
510
|
{renderHeader}
|
|
448
|
-
{viewToMeasureBoundedSize}
|
|
511
|
+
{!isHorizontalRTL && viewToMeasureBoundedSize}
|
|
449
512
|
{/* Main list content */}
|
|
450
513
|
<ViewHolderCollection
|
|
451
514
|
viewHolderCollectionRef={viewHolderCollectionRef}
|
|
@@ -453,6 +516,25 @@ const RecyclerViewComponent = <T,>(
|
|
|
453
516
|
horizontal={horizontal}
|
|
454
517
|
renderStack={recyclerViewManager.getRenderStack()}
|
|
455
518
|
getLayout={(index) => recyclerViewManager.getLayout(index)}
|
|
519
|
+
getAdjustmentMargin={() => {
|
|
520
|
+
if (!shouldRenderFromBottom || !recyclerViewManager.hasLayout()) {
|
|
521
|
+
return 0;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const windowSize = horizontal
|
|
525
|
+
? recyclerViewManager.getWindowSize().width
|
|
526
|
+
: recyclerViewManager.getWindowSize().height;
|
|
527
|
+
const childContainerSize = horizontal
|
|
528
|
+
? recyclerViewManager.getChildContainerDimensions().width
|
|
529
|
+
: recyclerViewManager.getChildContainerDimensions().height;
|
|
530
|
+
|
|
531
|
+
return Math.max(
|
|
532
|
+
0,
|
|
533
|
+
windowSize -
|
|
534
|
+
childContainerSize -
|
|
535
|
+
recyclerViewManager.firstItemOffset
|
|
536
|
+
);
|
|
537
|
+
}}
|
|
456
538
|
refHolder={refHolder}
|
|
457
539
|
onSizeChanged={validateItemSize}
|
|
458
540
|
renderItem={renderItem}
|
|
@@ -465,10 +547,14 @@ const RecyclerViewComponent = <T,>(
|
|
|
465
547
|
onCommitLayoutEffect?.();
|
|
466
548
|
}}
|
|
467
549
|
onCommitEffect={() => {
|
|
550
|
+
renderTimeTracker.markRenderComplete();
|
|
551
|
+
recyclerViewManager.updateAverageRenderTime(
|
|
552
|
+
renderTimeTracker.getAverageRenderTime()
|
|
553
|
+
);
|
|
468
554
|
applyInitialScrollIndex();
|
|
469
555
|
checkBounds();
|
|
470
556
|
recyclerViewManager.computeItemViewability();
|
|
471
|
-
recyclerViewManager.
|
|
557
|
+
recyclerViewManager.animationOptimizationsEnabled = false;
|
|
472
558
|
}}
|
|
473
559
|
CellRendererComponent={CellRendererComponent}
|
|
474
560
|
ItemSeparatorComponent={ItemSeparatorComponent}
|
|
@@ -487,9 +573,12 @@ const RecyclerViewComponent = <T,>(
|
|
|
487
573
|
);
|
|
488
574
|
};
|
|
489
575
|
|
|
576
|
+
// Set displayName for the inner component
|
|
577
|
+
RecyclerViewComponent.displayName = "FlashList";
|
|
578
|
+
|
|
490
579
|
// Type definition for the RecyclerView component
|
|
491
580
|
type RecyclerViewType = <T>(
|
|
492
|
-
props: RecyclerViewProps<T> & { ref?: React.Ref<
|
|
581
|
+
props: RecyclerViewProps<T> & { ref?: React.Ref<FlashListRef<T>> }
|
|
493
582
|
) => React.JSX.Element;
|
|
494
583
|
|
|
495
584
|
// Create and export the memoized, forwarded ref component
|
|
@@ -1,19 +1,65 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import { FlashListRef } from "../FlashListRef";
|
|
4
|
+
|
|
2
5
|
import { CompatScroller } from "./components/CompatScroller";
|
|
3
6
|
|
|
4
|
-
export interface RecyclerViewContext {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
export interface RecyclerViewContext<T> extends FlashListContext<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Mark the children FlashLists as pending for layout
|
|
10
|
+
* This will force parent FlashList to wait for children to be laid out before
|
|
11
|
+
* rendering the next batch of items.
|
|
12
|
+
* @param id - The id of the child FlashList
|
|
13
|
+
* @returns void
|
|
14
|
+
*/
|
|
8
15
|
markChildLayoutAsPending: (id: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Unmark the child FlashList as pending for layout
|
|
18
|
+
* This will allow parent FlashList to render the next batch of items.
|
|
19
|
+
* @param id - The id of the child FlashList
|
|
20
|
+
* @returns void
|
|
21
|
+
*/
|
|
9
22
|
unmarkChildLayoutAsPending: (id: string) => void;
|
|
10
23
|
}
|
|
11
24
|
|
|
25
|
+
export interface FlashListContext<T> {
|
|
26
|
+
/**
|
|
27
|
+
* Layout the current FlashList
|
|
28
|
+
* @returns void
|
|
29
|
+
*/
|
|
30
|
+
layout: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Get the ref for the current FlashList
|
|
33
|
+
*/
|
|
34
|
+
getRef: () => FlashListRef<T> | null;
|
|
35
|
+
/**
|
|
36
|
+
* Get the ref for the parent FlashList if present
|
|
37
|
+
*/
|
|
38
|
+
getParentRef: () => FlashListRef<unknown> | null;
|
|
39
|
+
/**
|
|
40
|
+
* Get the scrollView ref for the current FlashList if present
|
|
41
|
+
*/
|
|
42
|
+
getScrollViewRef: () => CompatScroller | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get the scrollView ref for the parent FlashList if present
|
|
45
|
+
*/
|
|
46
|
+
getParentScrollViewRef: () => CompatScroller | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
12
49
|
const RecyclerViewContextInstance = createContext<
|
|
13
|
-
RecyclerViewContext | undefined
|
|
50
|
+
RecyclerViewContext<unknown> | undefined
|
|
14
51
|
>(undefined);
|
|
15
52
|
|
|
16
53
|
export const RecyclerViewContextProvider = RecyclerViewContextInstance.Provider;
|
|
17
|
-
export function useRecyclerViewContext()
|
|
18
|
-
|
|
54
|
+
export function useRecyclerViewContext<T>():
|
|
55
|
+
| RecyclerViewContext<T>
|
|
56
|
+
| undefined {
|
|
57
|
+
return useContext(RecyclerViewContextInstance) as
|
|
58
|
+
| RecyclerViewContext<T>
|
|
59
|
+
| undefined;
|
|
60
|
+
}
|
|
61
|
+
export function useFlashListContext<T>(): FlashListContext<T> | undefined {
|
|
62
|
+
return useContext(RecyclerViewContextInstance) as
|
|
63
|
+
| FlashListContext<T>
|
|
64
|
+
| undefined;
|
|
19
65
|
}
|