@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.
Files changed (329) hide show
  1. package/README.md +67 -96
  2. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +2 -2
  3. package/dist/AnimatedFlashList.d.ts +0 -1
  4. package/dist/AnimatedFlashList.d.ts.map +1 -1
  5. package/dist/AnimatedFlashList.js +3 -3
  6. package/dist/AnimatedFlashList.js.map +1 -1
  7. package/dist/FlashList.d.ts +9 -0
  8. package/dist/FlashList.d.ts.map +1 -1
  9. package/dist/FlashList.js +22 -3
  10. package/dist/FlashList.js.map +1 -1
  11. package/dist/FlashListProps.d.ts +33 -13
  12. package/dist/FlashListProps.d.ts.map +1 -1
  13. package/dist/FlashListProps.js.map +1 -1
  14. package/dist/FlashListRef.d.ts +305 -0
  15. package/dist/FlashListRef.d.ts.map +1 -0
  16. package/dist/FlashListRef.js +3 -0
  17. package/dist/FlashListRef.js.map +1 -0
  18. package/dist/GridLayoutProviderWithProps.js +1 -2
  19. package/dist/GridLayoutProviderWithProps.js.map +1 -1
  20. package/dist/MasonryFlashList.d.ts +2 -2
  21. package/dist/MasonryFlashList.d.ts.map +1 -1
  22. package/dist/MasonryFlashList.js.map +1 -1
  23. package/dist/PureComponentWrapper.js +1 -1
  24. package/dist/PureComponentWrapper.js.map +1 -1
  25. package/dist/__tests__/AverageWindow.test.js.map +1 -1
  26. package/dist/__tests__/ConsecutiveNumbers.test.d.ts +2 -0
  27. package/dist/__tests__/ConsecutiveNumbers.test.d.ts.map +1 -0
  28. package/dist/__tests__/ConsecutiveNumbers.test.js +224 -0
  29. package/dist/__tests__/ConsecutiveNumbers.test.js.map +1 -0
  30. package/dist/__tests__/FlashList.test.js.map +1 -1
  31. package/dist/__tests__/GridLayoutManager.test.d.ts +2 -0
  32. package/dist/__tests__/GridLayoutManager.test.d.ts.map +1 -0
  33. package/dist/__tests__/GridLayoutManager.test.js +69 -0
  34. package/dist/__tests__/GridLayoutManager.test.js.map +1 -0
  35. package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +1 -1
  36. package/dist/__tests__/LayoutCommitObserver.test.d.ts +2 -0
  37. package/dist/__tests__/LayoutCommitObserver.test.d.ts.map +1 -0
  38. package/dist/__tests__/LayoutCommitObserver.test.js +35 -0
  39. package/dist/__tests__/LayoutCommitObserver.test.js.map +1 -0
  40. package/dist/__tests__/LinearLayoutManager.test.d.ts +2 -0
  41. package/dist/__tests__/LinearLayoutManager.test.d.ts.map +1 -0
  42. package/dist/__tests__/LinearLayoutManager.test.js +140 -0
  43. package/dist/__tests__/LinearLayoutManager.test.js.map +1 -0
  44. package/dist/__tests__/MasonryFlashList.test.js.map +1 -1
  45. package/dist/__tests__/MasonryLayoutManager.test.d.ts +2 -0
  46. package/dist/__tests__/MasonryLayoutManager.test.d.ts.map +1 -0
  47. package/dist/__tests__/MasonryLayoutManager.test.js +148 -0
  48. package/dist/__tests__/MasonryLayoutManager.test.js.map +1 -0
  49. package/dist/__tests__/RecyclerView.test.d.ts +2 -0
  50. package/dist/__tests__/RecyclerView.test.d.ts.map +1 -0
  51. package/dist/__tests__/RecyclerView.test.js +103 -0
  52. package/dist/__tests__/RecyclerView.test.js.map +1 -0
  53. package/dist/__tests__/RenderStackManager.test.d.ts +2 -0
  54. package/dist/__tests__/RenderStackManager.test.d.ts.map +1 -0
  55. package/dist/__tests__/RenderStackManager.test.js +485 -0
  56. package/dist/__tests__/RenderStackManager.test.js.map +1 -0
  57. package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
  58. package/dist/__tests__/findVisibleIndex.test.d.ts +2 -0
  59. package/dist/__tests__/findVisibleIndex.test.d.ts.map +1 -0
  60. package/dist/__tests__/findVisibleIndex.test.js +259 -0
  61. package/dist/__tests__/findVisibleIndex.test.js.map +1 -0
  62. package/dist/__tests__/helpers/createLayoutManager.d.ts +34 -0
  63. package/dist/__tests__/helpers/createLayoutManager.d.ts.map +1 -0
  64. package/dist/__tests__/helpers/createLayoutManager.js +110 -0
  65. package/dist/__tests__/helpers/createLayoutManager.js.map +1 -0
  66. package/dist/__tests__/helpers/mountFlashList.d.ts +2 -2
  67. package/dist/__tests__/helpers/mountFlashList.d.ts.map +1 -1
  68. package/dist/__tests__/helpers/mountFlashList.js +2 -2
  69. package/dist/__tests__/helpers/mountFlashList.js.map +1 -1
  70. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +2 -2
  71. package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +1 -1
  72. package/dist/__tests__/helpers/mountMasonryFlashList.js +2 -2
  73. package/dist/__tests__/helpers/mountMasonryFlashList.js.map +1 -1
  74. package/dist/__tests__/useBlankAreaTracker.test.js.map +1 -1
  75. package/dist/__tests__/useUnmountAwareCallbacks.test.d.ts +2 -0
  76. package/dist/__tests__/useUnmountAwareCallbacks.test.d.ts.map +1 -0
  77. package/dist/__tests__/useUnmountAwareCallbacks.test.js +185 -0
  78. package/dist/__tests__/useUnmountAwareCallbacks.test.js.map +1 -0
  79. package/dist/benchmark/AutoScrollHelper.js +2 -2
  80. package/dist/benchmark/AutoScrollHelper.js.map +1 -1
  81. package/dist/benchmark/JSFPSMonitor.js.map +1 -1
  82. package/dist/benchmark/roundToDecimalPlaces.js +1 -2
  83. package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
  84. package/dist/benchmark/useBenchmark.js +2 -28
  85. package/dist/benchmark/useBenchmark.js.map +1 -1
  86. package/dist/benchmark/useBlankAreaTracker.js +1 -2
  87. package/dist/benchmark/useBlankAreaTracker.js.map +1 -1
  88. package/dist/benchmark/useDataMultiplier.js +1 -2
  89. package/dist/benchmark/useDataMultiplier.js.map +1 -1
  90. package/dist/benchmark/useFlatListBenchmark.d.ts +0 -1
  91. package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
  92. package/dist/benchmark/useFlatListBenchmark.js +9 -9
  93. package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
  94. package/dist/enableNewCore.d.ts.map +1 -1
  95. package/dist/enableNewCore.js +4 -4
  96. package/dist/enableNewCore.js.map +1 -1
  97. package/dist/errors/CustomError.js.map +1 -1
  98. package/dist/index.d.ts +4 -1
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +11 -3
  101. package/dist/index.js.map +1 -1
  102. package/dist/native/auto-layout/AutoLayoutView.d.ts +1 -1
  103. package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -1
  104. package/dist/native/auto-layout/AutoLayoutView.js +1 -1
  105. package/dist/native/auto-layout/AutoLayoutView.js.map +1 -1
  106. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -1
  107. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +1 -1
  108. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -1
  109. package/dist/native/config/PlatformHelper.android.d.ts +2 -0
  110. package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
  111. package/dist/native/config/PlatformHelper.android.js +2 -0
  112. package/dist/native/config/PlatformHelper.android.js.map +1 -1
  113. package/dist/native/config/PlatformHelper.d.ts +2 -0
  114. package/dist/native/config/PlatformHelper.d.ts.map +1 -1
  115. package/dist/native/config/PlatformHelper.ios.d.ts +2 -0
  116. package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
  117. package/dist/native/config/PlatformHelper.ios.js +2 -0
  118. package/dist/native/config/PlatformHelper.ios.js.map +1 -1
  119. package/dist/native/config/PlatformHelper.js +2 -0
  120. package/dist/native/config/PlatformHelper.js.map +1 -1
  121. package/dist/native/config/PlatformHelper.web.d.ts +2 -0
  122. package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
  123. package/dist/native/config/PlatformHelper.web.js +3 -1
  124. package/dist/native/config/PlatformHelper.web.js.map +1 -1
  125. package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
  126. package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
  127. package/dist/recyclerview/LayoutCommitObserver.js +62 -0
  128. package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
  129. package/dist/recyclerview/RecyclerView.d.ts +3 -2
  130. package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
  131. package/dist/recyclerview/RecyclerView.js +133 -69
  132. package/dist/recyclerview/RecyclerView.js.map +1 -1
  133. package/dist/recyclerview/RecyclerViewContextProvider.d.ts +41 -7
  134. package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -1
  135. package/dist/recyclerview/RecyclerViewContextProvider.js +6 -2
  136. package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -1
  137. package/dist/recyclerview/RecyclerViewManager.d.ts +31 -7
  138. package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
  139. package/dist/recyclerview/RecyclerViewManager.js +154 -117
  140. package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
  141. package/dist/recyclerview/RecyclerViewProps.d.ts +1 -1
  142. package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
  143. package/dist/recyclerview/RenderStackManager.d.ts +86 -0
  144. package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
  145. package/dist/recyclerview/RenderStackManager.js +343 -0
  146. package/dist/recyclerview/RenderStackManager.js.map +1 -0
  147. package/dist/recyclerview/ViewHolder.d.ts.map +1 -1
  148. package/dist/recyclerview/ViewHolder.js +8 -6
  149. package/dist/recyclerview/ViewHolder.js.map +1 -1
  150. package/dist/recyclerview/ViewHolderCollection.d.ts +10 -4
  151. package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -1
  152. package/dist/recyclerview/ViewHolderCollection.js +26 -10
  153. package/dist/recyclerview/ViewHolderCollection.js.map +1 -1
  154. package/dist/recyclerview/components/ScrollAnchor.d.ts +2 -1
  155. package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -1
  156. package/dist/recyclerview/components/ScrollAnchor.js +12 -9
  157. package/dist/recyclerview/components/ScrollAnchor.js.map +1 -1
  158. package/dist/recyclerview/components/StickyHeaders.d.ts +2 -2
  159. package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -1
  160. package/dist/recyclerview/components/StickyHeaders.js +44 -45
  161. package/dist/recyclerview/components/StickyHeaders.js.map +1 -1
  162. package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +1 -1
  163. package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -1
  164. package/dist/recyclerview/helpers/ConsecutiveNumbers.js +2 -2
  165. package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -1
  166. package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +48 -2
  167. package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -1
  168. package/dist/recyclerview/helpers/EngagedIndicesTracker.js +89 -19
  169. package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -1
  170. package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +11 -0
  171. package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
  172. package/dist/recyclerview/helpers/RenderTimeTracker.js +42 -0
  173. package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
  174. package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
  175. package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
  176. package/dist/recyclerview/helpers/VelocityTracker.js +70 -0
  177. package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
  178. package/dist/recyclerview/hooks/useBoundDetection.d.ts +1 -3
  179. package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -1
  180. package/dist/recyclerview/hooks/useBoundDetection.js +60 -28
  181. package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -1
  182. package/dist/recyclerview/hooks/useLayoutState.d.ts +3 -1
  183. package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -1
  184. package/dist/recyclerview/hooks/useLayoutState.js +6 -5
  185. package/dist/recyclerview/hooks/useLayoutState.js.map +1 -1
  186. package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
  187. package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
  188. package/dist/recyclerview/hooks/useMappingHelper.js +19 -0
  189. package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
  190. package/dist/recyclerview/hooks/useOnLoad.d.ts +2 -2
  191. package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -1
  192. package/dist/recyclerview/hooks/useOnLoad.js +9 -10
  193. package/dist/recyclerview/hooks/useOnLoad.js.map +1 -1
  194. package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +5 -49
  195. package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
  196. package/dist/recyclerview/hooks/useRecyclerViewController.js +343 -191
  197. package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
  198. package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +2 -0
  199. package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -1
  200. package/dist/recyclerview/hooks/useRecyclerViewManager.js +11 -1
  201. package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -1
  202. package/dist/recyclerview/hooks/useRecyclingState.d.ts +4 -2
  203. package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -1
  204. package/dist/recyclerview/hooks/useRecyclingState.js +3 -4
  205. package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -1
  206. package/dist/recyclerview/hooks/useSecondaryProps.d.ts +1 -1
  207. package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -1
  208. package/dist/recyclerview/hooks/useSecondaryProps.js +15 -12
  209. package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -1
  210. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
  211. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
  212. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +63 -0
  213. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
  214. package/dist/recyclerview/hooks/useUnmountFlag.d.ts +0 -1
  215. package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -1
  216. package/dist/recyclerview/hooks/useUnmountFlag.js +1 -0
  217. package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -1
  218. package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +18 -4
  219. package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -1
  220. package/dist/recyclerview/layout-managers/GridLayoutManager.js +61 -25
  221. package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -1
  222. package/dist/recyclerview/layout-managers/LayoutManager.d.ts +36 -21
  223. package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
  224. package/dist/recyclerview/layout-managers/LayoutManager.js +96 -28
  225. package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
  226. package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +1 -2
  227. package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -1
  228. package/dist/recyclerview/layout-managers/LinearLayoutManager.js +3 -3
  229. package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -1
  230. package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +9 -1
  231. package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -1
  232. package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +30 -16
  233. package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -1
  234. package/dist/recyclerview/utils/adjustOffsetForRTL.js +1 -2
  235. package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -1
  236. package/dist/recyclerview/utils/componentUtils.d.ts +1 -1
  237. package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -1
  238. package/dist/recyclerview/utils/componentUtils.js.map +1 -1
  239. package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -1
  240. package/dist/recyclerview/utils/findVisibleIndex.js +3 -5
  241. package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -1
  242. package/dist/recyclerview/utils/measureLayout.d.ts +24 -28
  243. package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -1
  244. package/dist/recyclerview/utils/measureLayout.js +36 -6
  245. package/dist/recyclerview/utils/measureLayout.js.map +1 -1
  246. package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
  247. package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
  248. package/dist/recyclerview/utils/measureLayout.web.js +87 -0
  249. package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
  250. package/dist/specs/AutoLayoutNativeComponent.d.ts +1 -2
  251. package/dist/specs/AutoLayoutNativeComponent.d.ts.map +1 -1
  252. package/dist/specs/CellContainerNativeComponent.d.ts +0 -1
  253. package/dist/specs/CellContainerNativeComponent.d.ts.map +1 -1
  254. package/dist/tsconfig.tsbuildinfo +1 -1
  255. package/dist/utils/AverageWindow.js.map +1 -1
  256. package/dist/utils/ContentContainerUtils.d.ts.map +1 -1
  257. package/dist/utils/ContentContainerUtils.js.map +1 -1
  258. package/dist/viewability/ViewToken.d.ts +2 -2
  259. package/dist/viewability/ViewToken.d.ts.map +1 -1
  260. package/dist/viewability/ViewabilityHelper.js +1 -1
  261. package/dist/viewability/ViewabilityHelper.js.map +1 -1
  262. package/dist/viewability/ViewabilityManager.d.ts.map +1 -1
  263. package/dist/viewability/ViewabilityManager.js +11 -5
  264. package/dist/viewability/ViewabilityManager.js.map +1 -1
  265. package/jestSetup.js +30 -11
  266. package/package.json +4 -3
  267. package/src/AnimatedFlashList.ts +3 -2
  268. package/src/FlashList.tsx +25 -1
  269. package/src/FlashListProps.ts +42 -11
  270. package/src/FlashListRef.ts +320 -0
  271. package/src/MasonryFlashList.tsx +2 -2
  272. package/src/__tests__/ConsecutiveNumbers.test.ts +232 -0
  273. package/src/__tests__/GridLayoutManager.test.ts +113 -0
  274. package/src/__tests__/LayoutCommitObserver.test.tsx +60 -0
  275. package/src/__tests__/LinearLayoutManager.test.ts +227 -0
  276. package/src/__tests__/MasonryLayoutManager.test.ts +202 -0
  277. package/src/__tests__/RecyclerView.test.tsx +144 -0
  278. package/src/__tests__/RenderStackManager.test.ts +574 -0
  279. package/src/__tests__/findVisibleIndex.test.ts +369 -0
  280. package/src/__tests__/helpers/createLayoutManager.ts +141 -0
  281. package/src/__tests__/useUnmountAwareCallbacks.test.tsx +285 -0
  282. package/src/benchmark/useBenchmark.ts +0 -37
  283. package/src/benchmark/useFlatListBenchmark.ts +2 -2
  284. package/src/enableNewCore.ts +3 -1
  285. package/src/index.ts +14 -3
  286. package/src/native/config/PlatformHelper.android.ts +2 -0
  287. package/src/native/config/PlatformHelper.ios.ts +2 -0
  288. package/src/native/config/PlatformHelper.ts +2 -0
  289. package/src/native/config/PlatformHelper.web.ts +3 -1
  290. package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
  291. package/src/recyclerview/RecyclerView.tsx +178 -89
  292. package/src/recyclerview/RecyclerViewContextProvider.ts +53 -7
  293. package/src/recyclerview/RecyclerViewManager.ts +176 -97
  294. package/src/recyclerview/RecyclerViewProps.ts +2 -1
  295. package/src/recyclerview/RenderStackManager.ts +317 -0
  296. package/src/recyclerview/ViewHolder.tsx +13 -6
  297. package/src/recyclerview/ViewHolderCollection.tsx +45 -16
  298. package/src/recyclerview/components/ScrollAnchor.tsx +24 -11
  299. package/src/recyclerview/components/StickyHeaders.tsx +70 -58
  300. package/src/recyclerview/helpers/ConsecutiveNumbers.ts +2 -2
  301. package/src/recyclerview/helpers/EngagedIndicesTracker.ts +135 -25
  302. package/src/recyclerview/helpers/RenderTimeTracker.ts +42 -0
  303. package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
  304. package/src/recyclerview/hooks/useBoundDetection.ts +74 -25
  305. package/src/recyclerview/hooks/useLayoutState.ts +15 -6
  306. package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
  307. package/src/recyclerview/hooks/useOnLoad.ts +11 -10
  308. package/src/recyclerview/hooks/useRecyclerViewController.tsx +380 -241
  309. package/src/recyclerview/hooks/useRecyclerViewManager.ts +13 -1
  310. package/src/recyclerview/hooks/useRecyclingState.ts +11 -7
  311. package/src/recyclerview/hooks/useSecondaryProps.tsx +12 -7
  312. package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
  313. package/src/recyclerview/hooks/useUnmountFlag.ts +1 -0
  314. package/src/recyclerview/layout-managers/GridLayoutManager.ts +68 -27
  315. package/src/recyclerview/layout-managers/LayoutManager.ts +116 -42
  316. package/src/recyclerview/layout-managers/LinearLayoutManager.ts +12 -8
  317. package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +34 -13
  318. package/src/recyclerview/utils/componentUtils.ts +1 -1
  319. package/src/recyclerview/utils/findVisibleIndex.ts +1 -2
  320. package/src/recyclerview/utils/measureLayout.ts +41 -2
  321. package/src/recyclerview/utils/measureLayout.web.ts +102 -0
  322. package/src/viewability/ViewToken.ts +2 -2
  323. package/src/viewability/ViewabilityHelper.ts +1 -1
  324. package/src/viewability/ViewabilityManager.ts +16 -9
  325. package/dist/recyclerview/RecycleKeyManager.d.ts +0 -82
  326. package/dist/recyclerview/RecycleKeyManager.d.ts.map +0 -1
  327. package/dist/recyclerview/RecycleKeyManager.js +0 -135
  328. package/dist/recyclerview/RecycleKeyManager.js.map +0 -1
  329. package/src/recyclerview/RecycleKeyManager.ts +0 -185
@@ -1 +1 @@
1
- {"version":3,"file":"ViewabilityManager.js","sourceRoot":"","sources":["../../src/viewability/ViewabilityManager.ts"],"names":[],"mappings":";;;AAIA,kFAAoD;AAGpD;;GAEG;AACH;IAKE,4BAAY,YAA0B;QAAtC,iBAuBC;;QA1BO,uBAAkB,GAAwB,EAAE,CAAC;QAC7C,kBAAa,GAAG,KAAK,CAAC;QAkCvB,YAAO,GAAG;YACf,KAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAC,iBAAiB;gBAChD,OAAA,iBAAiB,CAAC,OA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est.requireActual("@shopify/flash-list").FlashList;
3
- class MockFlashList extends ActualFlashList {
4
- componentDidMount() {
5
- super.componentDidMount();
6
- this.rlvRef?._scrollComponent?._scrollViewRef?.props.onLayout({
7
- nativeEvent: { layout: { height: 900, width: 400 } },
8
- });
9
- }
10
- }
2
+ const RecyclerView = jest.requireActual("@shopify/flash-list").RecyclerView;
3
+
11
4
  return {
12
5
  ...jest.requireActual("@shopify/flash-list"),
13
- FlashList: MockFlashList,
14
- AnimatedFlashList: MockFlashList,
6
+ FlashList: RecyclerView,
7
+ };
8
+ });
9
+
10
+ jest.mock("@shopify/flash-list/dist/recyclerview/utils/measureLayout", () => {
11
+ const originalModule = jest.requireActual(
12
+ "@shopify/flash-list/dist/recyclerview/utils/measureLayout"
13
+ );
14
+ return {
15
+ ...originalModule,
16
+ measureParentSize: jest.fn().mockImplementation(() => ({
17
+ x: 0,
18
+ y: 0,
19
+ width: 400,
20
+ height: 900,
21
+ })),
22
+ measureFirstChildLayout: jest.fn().mockImplementation(() => ({
23
+ x: 0,
24
+ y: 0,
25
+ width: 400,
26
+ height: 900,
27
+ })),
28
+ measureItemLayout: jest.fn().mockImplementation(() => ({
29
+ x: 0,
30
+ y: 0,
31
+ width: 100,
32
+ height: 100,
33
+ })),
15
34
  };
16
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/flash-list",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.21",
4
4
  "keywords": [
5
5
  "react-native",
6
6
  "recyclerview",
@@ -35,6 +35,7 @@
35
35
  "lint:fix": "yarn eslint . --ext .ts,.tsx --fix",
36
36
  "type-check": "yarn tsc --pretty --noEmit",
37
37
  "build": "tsc -b",
38
+ "watch-web": "sh fixture/web/scripts/copy-dist.sh",
38
39
  "prepublishOnly": "yarn run build",
39
40
  "fixture:rn:up": "cd fixture/react-native && yarn && cd ios && bundle exec pod install && cd ../../../",
40
41
  "fixture:expo:up": "cd fixture/expo && yarn && cd ../../",
@@ -46,7 +47,7 @@
46
47
  "rw": "yarn fixture:expo:start",
47
48
  "e2e:up": "cd fixture/react-native/ios && brew tap wix/brew && brew install applesimutils && cd ../../../",
48
49
  "e2e:ios": "cd fixture/react-native && yarn e2e:build:ios && yarn e2e:test:ios",
49
- "rei": "yarn run-e2e-ios",
50
+ "rei": "yarn run e2e:ios",
50
51
  "e2e:android": "cd fixture/react-native && yarn e2e:build:android && yarn e2e:test:android",
51
52
  "rea": "yarn run-e2e-android",
52
53
  "predeploy:website": "sh ./build_website.sh",
@@ -75,7 +76,7 @@
75
76
  "react": "18.3.1",
76
77
  "react-native": "0.76.5",
77
78
  "react-test-renderer": "18.2.0",
78
- "typescript": "^4.7.4"
79
+ "typescript": "5.8.3"
79
80
  },
80
81
  "files": [
81
82
  "android",
@@ -1,11 +1,12 @@
1
1
  import { Animated } from "react-native";
2
2
 
3
- import FlashList from "./FlashList";
4
3
  import { FlashListProps } from "./FlashListProps";
4
+ import { RecyclerView } from "./recyclerview/RecyclerView";
5
5
 
6
+ // Typecast as required
6
7
  const AnimatedFlashList =
7
8
  Animated.createAnimatedComponent<React.ComponentType<FlashListProps<any>>>(
8
- FlashList
9
+ RecyclerView
9
10
  );
10
11
 
11
12
  export default AnimatedFlashList;
package/src/FlashList.tsx CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  hasUnsupportedKeysInContentContainerStyle,
43
43
  updateContentStyle,
44
44
  } from "./utils/ContentContainerUtils";
45
+ import { ScrollToEdgeParams } from "./FlashListRef";
45
46
 
46
47
  interface StickyProps extends StickyContainerProps {
47
48
  children: any;
@@ -624,7 +625,7 @@ class FlashList<T> extends React.PureComponent<
624
625
  private getValidComponent(
625
626
  component: React.ComponentType | React.ReactElement | null | undefined
626
627
  ) {
627
- const PassedComponent = component;
628
+ const PassedComponent = component as any;
628
629
  return (
629
630
  (React.isValidElement(PassedComponent) && PassedComponent) ||
630
631
  (PassedComponent && <PassedComponent />) ||
@@ -924,6 +925,29 @@ class FlashList<T> extends React.PureComponent<
924
925
  public getFirstVisibleIndex() {
925
926
  return this.rlvRef?.findApproxFirstVisibleIndex() ?? -1;
926
927
  }
928
+
929
+ flashScrollIndicators() {
930
+ this.getNativeScrollRef()?.flashScrollIndicators();
931
+ }
932
+
933
+ getNativeScrollRef() {
934
+ return (this.rlvRef as any)?._scrollComponent?._scrollViewRef;
935
+ }
936
+
937
+ getScrollResponder() {
938
+ return this.getNativeScrollRef()?.getScrollResponder();
939
+ }
940
+
941
+ scrollToTop(params?: ScrollToEdgeParams) {
942
+ this.rlvRef?.scrollToTop(params?.animated);
943
+ }
944
+
945
+ computeVisibleIndices() {
946
+ console.warn(
947
+ "computeVisibleIndices is not implemented in old architecture"
948
+ );
949
+ return { startIndex: -1, endIndex: -2 };
950
+ }
927
951
  }
928
952
 
929
953
  export default FlashList;
@@ -3,7 +3,6 @@ import {
3
3
  StyleProp,
4
4
  ScrollViewProps,
5
5
  ViewabilityConfig,
6
- ViewabilityConfigCallbackPairs,
7
6
  ViewStyle,
8
7
  } from "react-native";
9
8
 
@@ -23,6 +22,12 @@ export interface ListRenderItemInfo<TItem> {
23
22
  extraData?: any;
24
23
  }
25
24
 
25
+ export interface OverrideProps {
26
+ initialDrawBatchSize?: number;
27
+ // rest can be string to any
28
+ [key: string]: any;
29
+ }
30
+
26
31
  export type RenderTarget = "Cell" | "StickyHeader" | "Measurement";
27
32
 
28
33
  export const RenderTargetOptions: Record<string, RenderTarget> = {
@@ -47,6 +52,19 @@ export type ContentStyle = Pick<
47
52
  | "paddingHorizontal"
48
53
  >;
49
54
 
55
+ export interface ViewabilityConfigCallbackPair<TItem> {
56
+ viewabilityConfig: ViewabilityConfig;
57
+ onViewableItemsChanged:
58
+ | ((info: {
59
+ viewableItems: ViewToken<TItem>[];
60
+ changed: ViewToken<TItem>[];
61
+ }) => void)
62
+ | null;
63
+ }
64
+
65
+ export type ViewabilityConfigCallbackPairs<TItem> =
66
+ ViewabilityConfigCallbackPair<TItem>[];
67
+
50
68
  export interface FlashListProps<TItem>
51
69
  extends Omit<ScrollViewProps, "maintainVisibleContentPosition"> {
52
70
  /**
@@ -248,7 +266,10 @@ export interface FlashListProps<TItem>
248
266
  * they might be deferred until JS thread is less busy.
249
267
  */
250
268
  onViewableItemsChanged?:
251
- | ((info: { viewableItems: ViewToken[]; changed: ViewToken[] }) => void)
269
+ | ((info: {
270
+ viewableItems: ViewToken<TItem>[];
271
+ changed: ViewToken<TItem>[];
272
+ }) => void)
252
273
  | null
253
274
  | undefined;
254
275
 
@@ -293,7 +314,7 @@ export interface FlashListProps<TItem>
293
314
  /**
294
315
  * For debugging and exception use cases, internal props will be overriden with these values if used
295
316
  */
296
- overrideProps?: object;
317
+ overrideProps?: OverrideProps;
297
318
 
298
319
  /**
299
320
  * Set this when offset is needed for the loading indicator to show correctly.
@@ -317,7 +338,9 @@ export interface FlashListProps<TItem>
317
338
  * List of `ViewabilityConfig`/`onViewableItemsChanged` pairs.
318
339
  * A specific `onViewableItemsChanged` will be called when its corresponding `ViewabilityConfig`'s conditions are met.
319
340
  */
320
- viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
341
+ viewabilityConfigCallbackPairs?:
342
+ | ViewabilityConfigCallbackPairs<TItem>
343
+ | undefined;
321
344
 
322
345
  /**
323
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
@@ -334,6 +357,15 @@ export interface FlashListProps<TItem>
334
357
  */
335
358
  disableAutoLayout?: boolean;
336
359
 
360
+ /**
361
+ * New arch only
362
+ * 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.
363
+ * Unless you have a huge number of item types, you shouldn't need to set this.
364
+ * Setting this to 0, will disable the recycle pool and items will unmount once they are scrolled off the screen.
365
+ * There's no limit by default.
366
+ */
367
+ maxItemsInRecyclePool?: number;
368
+
337
369
  /**
338
370
  * New arch only
339
371
  * Enable masonry layout.
@@ -343,7 +375,7 @@ export interface FlashListProps<TItem>
343
375
  * New arch only
344
376
  * If enabled, MasonryFlashList will try to reduce difference in column height by modifying item order.
345
377
  */
346
- optimizeItemArrangement?: boolean; //TODO: Check if this breaks on item resize or is glitchy
378
+ optimizeItemArrangement?: boolean; // TODO: Check if this breaks on item resize or is glitchy
347
379
 
348
380
  /**
349
381
  * New arch only
@@ -360,12 +392,6 @@ export interface FlashListProps<TItem>
360
392
  */
361
393
  onStartReachedThreshold?: FlashListProps<TItem>["onEndReachedThreshold"];
362
394
 
363
- /**
364
- * New arch only
365
- * If true, the RecyclerView will not recycle items.
366
- */
367
- disableRecycling?: boolean;
368
-
369
395
  /**
370
396
  * New arch only
371
397
  * Style for the RecyclerView's parent container.
@@ -391,6 +417,11 @@ export interface FlashListProps<TItem>
391
417
  * When content is added at the bottom, automatically scroll to maintain position if the user is within this threshold of the bottom
392
418
  */
393
419
  autoscrollToBottomThreshold?: number;
420
+ /**
421
+ * Scroll with animation whenever `autoscrollToBottom` is triggered. Default is `true`.
422
+ * Default is true.
423
+ */
424
+ animateAutoScrollToBottom?: boolean;
394
425
  /**
395
426
  * If true, initial render will start from the bottom of the list, useful for chat-like interfaces when there are only few messages
396
427
  */
@@ -0,0 +1,320 @@
1
+ import type { RVLayout } from "./recyclerview/layout-managers/LayoutManager";
2
+ import { RecyclerViewProps } from "./recyclerview/RecyclerViewProps";
3
+ import { CompatScroller } from "./recyclerview/components/CompatScroller";
4
+
5
+ /**
6
+ * Base parameters for scrolling to the edges of the list.
7
+ */
8
+ export interface ScrollToEdgeParams {
9
+ /** Whether the scroll should be animated */
10
+ animated?: boolean;
11
+ }
12
+
13
+ /**
14
+ * Parameters for scrolling to a specific position in the list.
15
+ * Extends ScrollToEdgeParams to include view positioning options.
16
+ */
17
+ export interface ScrollToParams extends ScrollToEdgeParams {
18
+ /** Position of the target item relative to the viewport (0 = top, 0.5 = center, 1 = bottom) */
19
+ viewPosition?: number;
20
+ /** Additional offset to apply after viewPosition calculation */
21
+ viewOffset?: number;
22
+ }
23
+
24
+ /**
25
+ * Parameters for scrolling to a specific offset in the list.
26
+ * Used when you want to scroll to an exact pixel position.
27
+ */
28
+ export interface ScrollToOffsetParams extends ScrollToParams {
29
+ /** The pixel offset to scroll to */
30
+ offset: number;
31
+ /**
32
+ * If true, the first item offset will not be added to the offset calculation.
33
+ * First offset represents header size or top padding.
34
+ */
35
+ skipFirstItemOffset?: boolean;
36
+ }
37
+
38
+ /**
39
+ * Parameters for scrolling to a specific index in the list.
40
+ * Used when you want to scroll to a specific item by its position in the data array.
41
+ */
42
+ export interface ScrollToIndexParams extends ScrollToParams {
43
+ /** The index of the item to scroll to */
44
+ index: number;
45
+ }
46
+
47
+ /**
48
+ * Parameters for scrolling to a specific item in the list.
49
+ * Used when you want to scroll to a specific item by its data value.
50
+ */
51
+ export interface ScrollToItemParams<T> extends ScrollToParams {
52
+ /** The item to scroll to */
53
+ item: T;
54
+ }
55
+
56
+ /**
57
+ * Interface for FlashList's ref object that provides imperative methods
58
+ * for controlling list behavior.
59
+ *
60
+ * Usage example:
61
+ * ```tsx
62
+ * const listRef = useRef<FlashListRef<ItemType>>(null);
63
+ *
64
+ * // Later in your component
65
+ * <FlashList
66
+ * ref={listRef}
67
+ * data={data}
68
+ * renderItem={renderItem}
69
+ * />
70
+ *
71
+ * // Somewhere else in your component
72
+ * listRef.current?.scrollToIndex({ index: 5, animated: true });
73
+ * ```
74
+ */
75
+ export interface FlashListRef<T> {
76
+ /**
77
+ * Get access to current props
78
+ */
79
+ props: RecyclerViewProps<T>;
80
+ /**
81
+ * Scrolls the list to a specific offset position.
82
+ *
83
+ * Use this method when you want precise control over the scroll position in pixels
84
+ * rather than by item index.
85
+ *
86
+ * @param params - Parameters for scrolling to offset
87
+ * @param params.offset - The pixel offset to scroll to
88
+ * @param params.animated - Whether the scroll should be animated (default: false)
89
+ * @param params.skipFirstItemOffset - If true, the first item offset (headers/padding)
90
+ * will not be included in calculation (default: true)
91
+ *
92
+ * @example
93
+ * // Scroll to 200px from the top/left
94
+ * listRef.current?.scrollToOffset({ offset: 200, animated: true });
95
+ */
96
+ scrollToOffset: (params: ScrollToOffsetParams) => void;
97
+
98
+ /**
99
+ * Makes the scroll indicators flash momentarily.
100
+ *
101
+ * Useful to indicate to users that there is more content to scroll.
102
+ *
103
+ * @example
104
+ * listRef.current?.flashScrollIndicators();
105
+ */
106
+ flashScrollIndicators: () => void;
107
+
108
+ /**
109
+ * Returns the underlying native scroll view reference.
110
+ *
111
+ * Use this when you need direct access to the native scroll component.
112
+ * This is generally not recommended for regular use.
113
+ *
114
+ * @returns The native scroll view reference
115
+ */
116
+ getNativeScrollRef: () => CompatScroller | null;
117
+
118
+ /**
119
+ * Returns a reference to the scroll responder.
120
+ *
121
+ * Useful for more advanced scroll handling and integrations.
122
+ *
123
+ * @returns The scroll responder
124
+ */
125
+ getScrollResponder: CompatScroller["getScrollResponder"];
126
+
127
+ /**
128
+ * Returns the underlying scrollable node.
129
+ *
130
+ * Primarily used for platform-specific integrations.
131
+ *
132
+ * @returns The scrollable node
133
+ */
134
+ getScrollableNode: () => any;
135
+
136
+ /**
137
+ * Scrolls to the end of the list.
138
+ *
139
+ * @param params - Optional parameters for scrolling
140
+ * @param params.animated - Whether the scroll should be animated (default: false)
141
+ *
142
+ * @example
143
+ * // Animate scroll to the end of the list
144
+ * listRef.current?.scrollToEnd({ animated: true });
145
+ */
146
+ scrollToEnd: (params?: ScrollToEdgeParams) => void;
147
+
148
+ /**
149
+ * Scrolls to the top (or start) of the list.
150
+ *
151
+ * @param params - Optional parameters for scrolling
152
+ * @param params.animated - Whether the scroll should be animated (default: false)
153
+ *
154
+ * @example
155
+ * // Smoothly scroll to the top
156
+ * listRef.current?.scrollToTop({ animated: true });
157
+ */
158
+ scrollToTop: (params?: ScrollToEdgeParams) => void;
159
+
160
+ /**
161
+ * Scrolls to a specific index in the list.
162
+ *
163
+ * This is the most common method to scroll to a particular item.
164
+ *
165
+ * @param params - Parameters for scrolling to index
166
+ * @param params.index - The index of the item to scroll to
167
+ * @param params.animated - Whether the scroll should be animated (default: false)
168
+ * @param params.viewPosition - Position of the item within the visible area:
169
+ * 0 = top/left, 0.5 = center, 1 = bottom/right (default: 0)
170
+ * @param params.viewOffset - Additional offset to apply after viewPosition calculation
171
+ *
172
+ * @returns A Promise that resolves when the scroll operation is complete
173
+ *
174
+ * @example
175
+ * // Scroll to the 5th item (index 4) and center it
176
+ * listRef.current?.scrollToIndex({
177
+ * index: 4,
178
+ * animated: true,
179
+ * viewPosition: 0.5
180
+ * });
181
+ */
182
+ scrollToIndex: (params: ScrollToIndexParams) => Promise<void>;
183
+
184
+ /**
185
+ * Scrolls to a specific item in the list.
186
+ *
187
+ * Similar to scrollToIndex, but works with the item reference instead of its index.
188
+ * Useful when you have a reference to an item but don't know its index.
189
+ *
190
+ * @param params - Parameters for scrolling to item
191
+ * @param params.item - The item object to scroll to
192
+ * @param params.animated - Whether the scroll should be animated (default: false)
193
+ * @param params.viewPosition - Position of the item within the visible area:
194
+ * 0 = top/left, 0.5 = center, 1 = bottom/right (default: 0)
195
+ * @param params.viewOffset - Additional offset to apply after viewPosition calculation
196
+ *
197
+ * @example
198
+ * // Scroll to a specific item
199
+ * const targetItem = data[10];
200
+ * listRef.current?.scrollToItem({
201
+ * item: targetItem,
202
+ * animated: true
203
+ * });
204
+ */
205
+ scrollToItem: (params: ScrollToItemParams<T>) => void;
206
+
207
+ /**
208
+ * Returns the offset of the first item (accounts for header/padding).
209
+ *
210
+ * Useful when implementing custom scroll behavior or calculating positions.
211
+ *
212
+ * @returns The pixel offset of the first item
213
+ */
214
+ getFirstItemOffset: () => number;
215
+
216
+ /**
217
+ * Returns the current viewport dimensions.
218
+ *
219
+ * @returns An object with width and height properties representing viewport size
220
+ */
221
+ getWindowSize: () => { width: number; height: number };
222
+
223
+ /**
224
+ * Returns the layout information for a specific item.
225
+ *
226
+ * Use this to get position and size information for an item at a given index.
227
+ *
228
+ * @param index - The index of the item to get layout information for
229
+ * @returns Layout information including x, y, width, and height
230
+ *
231
+ * @example
232
+ * const itemLayout = listRef.current?.getLayout(5);
233
+ * console.log(`Item 5 position: (${itemLayout.x}, ${itemLayout.y})`);
234
+ */
235
+ getLayout: (index: number) => RVLayout | undefined;
236
+
237
+ /**
238
+ * Returns the absolute last scroll offset.
239
+ *
240
+ * Useful for implementing custom scroll tracking functionality.
241
+ *
242
+ * @returns The last scroll offset in pixels
243
+ */
244
+ getAbsoluteLastScrollOffset: () => number;
245
+
246
+ /**
247
+ * Returns the dimensions of the child container.
248
+ *
249
+ * @returns An object with width and height properties
250
+ */
251
+ getChildContainerDimensions: () => { width: number; height: number };
252
+
253
+ /**
254
+ * Marks the list as having been interacted with.
255
+ *
256
+ * Call this method when you want to manually trigger the onViewableItemsChanged
257
+ * callback without an actual scroll event.
258
+ */
259
+ recordInteraction: () => void;
260
+
261
+ /**
262
+ * Returns the currently visible item indices.
263
+ *
264
+ * Use this to determine which items are currently visible to the user.
265
+ *
266
+ * @returns An object with startIndex and endIndex properties
267
+ *
268
+ * @example
269
+ * const { startIndex, endIndex } = listRef.current?.getVisibleIndices();
270
+ * console.log(`Visible items: ${startIndex} to ${endIndex}`);
271
+ */
272
+ computeVisibleIndices: () => { startIndex: number; endIndex: number };
273
+
274
+ /**
275
+ * Returns the index of the first visible item.
276
+ *
277
+ * Convenience method when you only need the first visible item.
278
+ *
279
+ * @returns The index of the first visible item
280
+ *
281
+ * @example
282
+ * const firstVisibleIndex = listRef.current?.getFirstVisibleIndex();
283
+ */
284
+ getFirstVisibleIndex: () => number;
285
+
286
+ /**
287
+ * Forces recalculation of viewable items (vieability callbacks).
288
+ *
289
+ * Call this after any operation that might affect item visibility but
290
+ * doesn't trigger a scroll event.
291
+ *
292
+ * @example
293
+ * // After manually changing item sizes
294
+ * listRef.current?.recomputeViewableItems();
295
+ */
296
+ recomputeViewableItems: () => void;
297
+
298
+ /**
299
+ * Disables item recycling in preparation for layout animations.
300
+ *
301
+ * Call this before performing layout animations to prevent visual glitches.
302
+ * Remember to reset disableRecycling after animations complete.
303
+ *
304
+ * @example
305
+ * // Before starting layout animations
306
+ * listRef.current?.prepareForLayoutAnimationRender();
307
+ */
308
+ prepareForLayoutAnimationRender: () => void;
309
+
310
+ /**
311
+ * Clears the layout cache on update.
312
+ * Call this when you want to clear the layout cache on update.
313
+ * Can be useful for carousals when orientation changes.
314
+ * This should be called before the render and not in an effect.
315
+ *
316
+ * @example
317
+ * listRef.current?.clearLayoutCacheOnUpdate();
318
+ */
319
+ clearLayoutCacheOnUpdate: () => void;
320
+ }
@@ -258,7 +258,7 @@ const MasonryFlashListComponent = React.forwardRef(
258
258
  ? (info) => {
259
259
  updateViewTokens(info.viewableItems);
260
260
  updateViewTokens(info.changed);
261
- onViewableItemsChanged?.(info);
261
+ onViewableItemsChanged?.(info as any);
262
262
  }
263
263
  : undefined
264
264
  }
@@ -437,7 +437,7 @@ const getFlashListScrollView = (
437
437
  FlashListScrollView.displayName = "FlashListScrollView";
438
438
  return FlashListScrollView;
439
439
  };
440
- const updateViewTokens = (tokens: ViewToken[]) => {
440
+ const updateViewTokens = (tokens: ViewToken<any>[]) => {
441
441
  const length = tokens.length;
442
442
  for (let i = 0; i < length; i++) {
443
443
  const token = tokens[i];