@office-iss/react-native-win32 0.70.2 → 0.71.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (559) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +2 -0
  3. package/.flowconfig +3 -6
  4. package/CHANGELOG.json +281 -43
  5. package/CHANGELOG.md +105 -24
  6. package/IntegrationTests/AccessibilityManagerTest.js +1 -1
  7. package/IntegrationTests/AppEventsTest.js +0 -1
  8. package/IntegrationTests/BUCK +0 -1
  9. package/IntegrationTests/GlobalEvalWithSourceUrlTest.js +1 -1
  10. package/IntegrationTests/ImageSnapshotTest.js +1 -1
  11. package/IntegrationTests/IntegrationTestsApp.js +2 -3
  12. package/IntegrationTests/SimpleSnapshotTest.js +1 -1
  13. package/IntegrationTests/SyncMethodTest.js +1 -1
  14. package/IntegrationTests/TimersTest.js +4 -4
  15. package/IntegrationTests/WebSocketTest.js +3 -3
  16. package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +80 -0
  17. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +4 -3
  18. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
  19. package/Libraries/Alert/Alert.d.ts +90 -0
  20. package/Libraries/Alert/Alert.js +7 -1
  21. package/Libraries/Alert/Alert.win32.js +1 -0
  22. package/Libraries/Alert/NativeAlertManager.js +2 -0
  23. package/Libraries/Alert/RCTAlertManager.ios.js +2 -1
  24. package/Libraries/Animated/Animated.d.ts +587 -0
  25. package/Libraries/Animated/Animated.js +13 -11
  26. package/Libraries/Animated/AnimatedEvent.js +12 -17
  27. package/Libraries/Animated/AnimatedImplementation.js +21 -23
  28. package/Libraries/Animated/AnimatedMock.js +11 -13
  29. package/Libraries/Animated/AnimatedWeb.js +2 -2
  30. package/Libraries/Animated/Easing.d.ts +37 -0
  31. package/Libraries/Animated/Easing.js +2 -2
  32. package/Libraries/Animated/NativeAnimatedHelper.js +32 -22
  33. package/Libraries/Animated/NativeAnimatedModule.js +1 -0
  34. package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
  35. package/Libraries/Animated/SpringConfig.js +2 -7
  36. package/Libraries/Animated/animations/Animation.js +3 -4
  37. package/Libraries/Animated/animations/DecayAnimation.js +5 -8
  38. package/Libraries/Animated/animations/SpringAnimation.js +9 -14
  39. package/Libraries/Animated/animations/TimingAnimation.js +9 -13
  40. package/Libraries/Animated/bezier.js +2 -2
  41. package/Libraries/Animated/components/AnimatedFlatList.js +5 -6
  42. package/Libraries/Animated/components/AnimatedImage.js +5 -6
  43. package/Libraries/Animated/components/AnimatedScrollView.js +110 -14
  44. package/Libraries/Animated/components/AnimatedSectionList.js +4 -5
  45. package/Libraries/Animated/components/AnimatedText.js +5 -6
  46. package/Libraries/Animated/components/AnimatedView.js +5 -6
  47. package/Libraries/Animated/createAnimatedComponent.js +13 -20
  48. package/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +2 -2
  49. package/Libraries/Animated/nodes/AnimatedAddition.js +6 -8
  50. package/Libraries/Animated/nodes/AnimatedColor.js +7 -7
  51. package/Libraries/Animated/nodes/AnimatedDiffClamp.js +6 -8
  52. package/Libraries/Animated/nodes/AnimatedDivision.js +7 -9
  53. package/Libraries/Animated/nodes/AnimatedInterpolation.js +7 -10
  54. package/Libraries/Animated/nodes/AnimatedModulo.js +6 -8
  55. package/Libraries/Animated/nodes/AnimatedMultiplication.js +7 -9
  56. package/Libraries/Animated/nodes/AnimatedNode.js +10 -8
  57. package/Libraries/Animated/nodes/AnimatedProps.js +12 -30
  58. package/Libraries/Animated/nodes/AnimatedStyle.js +12 -22
  59. package/Libraries/Animated/nodes/AnimatedSubtraction.js +7 -9
  60. package/Libraries/Animated/nodes/AnimatedTracking.js +8 -12
  61. package/Libraries/Animated/nodes/AnimatedTransform.js +38 -31
  62. package/Libraries/Animated/nodes/AnimatedValue.js +9 -10
  63. package/Libraries/Animated/nodes/AnimatedValueXY.js +4 -7
  64. package/Libraries/Animated/nodes/AnimatedWithChildren.js +4 -5
  65. package/Libraries/Animated/useAnimatedProps.js +8 -16
  66. package/Libraries/Animated/useAnimatedValue.d.ts +15 -0
  67. package/Libraries/Animated/useAnimatedValue.js +25 -0
  68. package/Libraries/AppState/AppState.d.ts +58 -0
  69. package/Libraries/AppState/AppState.js +3 -7
  70. package/Libraries/AppState/NativeAppState.js +1 -0
  71. package/Libraries/BatchedBridge/MessageQueue.js +9 -5
  72. package/Libraries/BatchedBridge/NativeModules.d.ts +25 -0
  73. package/Libraries/BatchedBridge/NativeModules.js +1 -0
  74. package/Libraries/Blob/BlobManager.js +5 -3
  75. package/Libraries/Blob/File.js +2 -3
  76. package/Libraries/Blob/FileReader.js +6 -5
  77. package/Libraries/Blob/NativeBlobModule.js +1 -0
  78. package/Libraries/Blob/NativeFileReaderModule.js +1 -0
  79. package/Libraries/Blob/URL.js +11 -9
  80. package/Libraries/BugReporting/NativeBugReporting.js +1 -0
  81. package/Libraries/BugReporting/getReactData.js +1 -1
  82. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +128 -0
  83. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.flow.js +208 -0
  84. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +40 -8
  85. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +40 -8
  86. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +1 -0
  87. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +5 -0
  88. package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +86 -0
  89. package/Libraries/Components/ActivityIndicator/ActivityIndicator.flow.js +58 -0
  90. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +7 -8
  91. package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +2 -3
  92. package/Libraries/Components/Button.d.ts +42 -0
  93. package/Libraries/Components/Button.flow.js +265 -0
  94. package/Libraries/Components/Button.js +62 -18
  95. package/Libraries/Components/Clipboard/Clipboard.d.ts +28 -0
  96. package/Libraries/Components/Clipboard/NativeClipboard.js +1 -0
  97. package/Libraries/Components/DatePicker/DatePickerIOS.android.js +4 -2
  98. package/Libraries/Components/DatePicker/DatePickerIOS.d.ts +92 -0
  99. package/Libraries/Components/{MaskedView/MaskedViewIOS.android.js → DatePicker/DatePickerIOS.flow.android.js} +3 -2
  100. package/Libraries/Components/DatePicker/DatePickerIOS.flow.ios.js +113 -0
  101. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +8 -7
  102. package/Libraries/Components/DatePicker/DatePickerIOS.win32.js +4 -2
  103. package/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +7 -6
  104. package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +1 -0
  105. package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +9 -8
  106. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +13 -14
  107. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +141 -0
  108. package/Libraries/Components/Keyboard/Keyboard.d.ts +109 -0
  109. package/Libraries/Components/Keyboard/Keyboard.js +35 -8
  110. package/Libraries/Components/Keyboard/KeyboardAvoidingView.d.ts +46 -0
  111. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +35 -15
  112. package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +1 -0
  113. package/Libraries/Components/Pressable/Pressable.d.ts +167 -0
  114. package/Libraries/Components/Pressable/Pressable.js +73 -15
  115. package/Libraries/Components/Pressable/Pressable.win32.js +77 -19
  116. package/Libraries/Components/Pressable/useAndroidRippleForView.js +6 -3
  117. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +3 -3
  118. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +83 -0
  119. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +2 -2
  120. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +1 -1
  121. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts +62 -0
  122. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +4 -4
  123. package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.win32.js +1 -1
  124. package/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +2 -2
  125. package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +5 -6
  126. package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +4 -4
  127. package/Libraries/Components/RefreshControl/RefreshControl.d.ts +87 -0
  128. package/Libraries/Components/RefreshControl/RefreshControl.js +4 -3
  129. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -3
  130. package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -1
  131. package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +24 -0
  132. package/Libraries/Components/SafeAreaView/SafeAreaView.flow.js +19 -0
  133. package/Libraries/Components/SafeAreaView/SafeAreaView.js +5 -4
  134. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +5 -4
  135. package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +2 -1
  136. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -1
  137. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -1
  138. package/Libraries/Components/ScrollView/ScrollView.d.ts +911 -0
  139. package/Libraries/Components/ScrollView/ScrollView.js +87 -52
  140. package/Libraries/Components/ScrollView/ScrollViewCommands.js +3 -3
  141. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -1
  142. package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +3 -3
  143. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +243 -269
  144. package/Libraries/Components/Slider/Slider.d.ts +132 -0
  145. package/Libraries/Components/Slider/Slider.js +9 -9
  146. package/Libraries/Components/Slider/SliderNativeComponent.js +4 -5
  147. package/Libraries/Components/Sound/NativeSoundManager.js +1 -0
  148. package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +1 -0
  149. package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +1 -0
  150. package/Libraries/Components/StatusBar/StatusBar.d.ts +138 -0
  151. package/Libraries/Components/StatusBar/StatusBar.js +7 -7
  152. package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +10 -10
  153. package/Libraries/Components/Switch/Switch.d.ts +115 -0
  154. package/Libraries/Components/Switch/Switch.js +7 -7
  155. package/Libraries/Components/Switch/SwitchNativeComponent.js +9 -4
  156. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +40 -12
  157. package/Libraries/Components/TextInput/InputAccessoryView.d.ts +34 -0
  158. package/Libraries/Components/TextInput/InputAccessoryView.js +3 -4
  159. package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +1 -1
  160. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +3 -2
  161. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +3 -2
  162. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +3 -1
  163. package/Libraries/Components/TextInput/TextInput.d.ts +840 -0
  164. package/Libraries/Components/TextInput/TextInput.flow.js +1057 -0
  165. package/Libraries/Components/TextInput/TextInput.js +344 -38
  166. package/Libraries/Components/TextInput/TextInput.win32.d.ts +1 -1
  167. package/Libraries/Components/TextInput/TextInput.win32.js +1 -1
  168. package/Libraries/Components/TextInput/TextInput.win32.js.map +1 -1
  169. package/Libraries/Components/TextInput/TextInputNativeCommands.js +2 -2
  170. package/Libraries/Components/TextInput/TextInputState.js +22 -5
  171. package/Libraries/Components/TextInput/TextInputState.win32.js +24 -5
  172. package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +1 -0
  173. package/Libraries/Components/ToastAndroid/ToastAndroid.d.ts +47 -0
  174. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  175. package/Libraries/Components/Touchable/Touchable.d.ts +90 -0
  176. package/Libraries/Components/Touchable/Touchable.flow.js +258 -0
  177. package/Libraries/Components/Touchable/Touchable.js +12 -12
  178. package/Libraries/Components/Touchable/Touchable.win32.js +12 -12
  179. package/Libraries/Components/Touchable/TouchableBounce.js +44 -10
  180. package/Libraries/Components/Touchable/TouchableHighlight.d.ts +68 -0
  181. package/Libraries/Components/Touchable/TouchableHighlight.js +32 -9
  182. package/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts +114 -0
  183. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +54 -20
  184. package/Libraries/Components/Touchable/TouchableOpacity.d.ts +109 -0
  185. package/Libraries/Components/Touchable/TouchableOpacity.js +54 -16
  186. package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +2 -1
  187. package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
  188. package/Libraries/Components/Touchable/TouchableWin32.js +0 -1
  189. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  190. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +143 -0
  191. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +64 -10
  192. package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +1 -1
  193. package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
  194. package/Libraries/Components/View/ReactNativeStyleAttributes.js +13 -2
  195. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  196. package/Libraries/Components/View/View.d.ts +29 -0
  197. package/Libraries/Components/View/View.js +91 -8
  198. package/Libraries/Components/View/View.win32.js +176 -89
  199. package/Libraries/Components/View/ViewAccessibility.d.ts +360 -0
  200. package/Libraries/Components/View/ViewAccessibility.js +70 -1
  201. package/Libraries/Components/View/ViewNativeComponent.js +3 -3
  202. package/Libraries/Components/View/ViewPropTypes.d.ts +245 -0
  203. package/Libraries/Components/View/ViewPropTypes.js +105 -13
  204. package/Libraries/Components/View/ViewPropTypes.win32.js +105 -13
  205. package/Libraries/Components/View/ViewWin32.Props.d.ts +6 -1
  206. package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
  207. package/Libraries/Core/Devtools/openFileInEditor.js +3 -0
  208. package/Libraries/Core/Devtools/parseErrorStack.js +1 -1
  209. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
  210. package/Libraries/Core/ExceptionsManager.js +8 -0
  211. package/Libraries/Core/ExtendedError.js +11 -8
  212. package/Libraries/Core/InitializeCore.js +2 -1
  213. package/Libraries/Core/NativeExceptionsManager.js +3 -4
  214. package/Libraries/Core/RawEventEmitter.js +2 -1
  215. package/Libraries/Core/ReactFiberErrorDialog.js +2 -2
  216. package/Libraries/Core/ReactNativeVersion.js +2 -2
  217. package/Libraries/Core/ReactNativeVersionCheck.js +1 -0
  218. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -0
  219. package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +1 -0
  220. package/Libraries/Core/Timers/JSTimers.js +13 -11
  221. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  222. package/Libraries/Core/setUpBatchedBridge.js +1 -5
  223. package/Libraries/Core/setUpDeveloperTools.js +4 -6
  224. package/Libraries/Core/setUpReactDevTools.js +4 -1
  225. package/Libraries/Core/setUpRegeneratorRuntime.js +1 -1
  226. package/Libraries/Core/setUpTimers.js +1 -1
  227. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +70 -0
  228. package/Libraries/EventEmitter/NativeEventEmitter.js +1 -0
  229. package/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +30 -0
  230. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
  231. package/Libraries/EventEmitter/RCTNativeAppEventEmitter.d.ts +32 -0
  232. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +1 -0
  233. package/Libraries/Events/EventPolyfill.js +1 -1
  234. package/Libraries/HeapCapture/NativeJSCHeapCapture.js +1 -0
  235. package/Libraries/Image/AssetSourceResolver.js +4 -6
  236. package/Libraries/Image/Image.android.js +63 -45
  237. package/Libraries/Image/Image.d.ts +322 -0
  238. package/Libraries/Image/Image.flow.js +64 -0
  239. package/Libraries/Image/Image.ios.js +55 -28
  240. package/Libraries/Image/Image.win32.js +54 -25
  241. package/Libraries/Image/ImageBackground.js +18 -7
  242. package/Libraries/Image/ImageInjection.js +2 -1
  243. package/Libraries/Image/ImageProps.js +88 -5
  244. package/Libraries/Image/ImageResizeMode.d.ts +49 -0
  245. package/Libraries/Image/ImageSource.d.ts +76 -0
  246. package/Libraries/Image/ImageSourceUtils.js +80 -0
  247. package/Libraries/Image/ImageUtils.js +21 -0
  248. package/Libraries/Image/ImageViewNativeComponent.js +8 -5
  249. package/Libraries/Image/NativeImageEditor.js +1 -0
  250. package/Libraries/Image/NativeImageLoaderAndroid.js +1 -0
  251. package/Libraries/Image/NativeImageLoaderIOS.js +1 -0
  252. package/Libraries/Image/NativeImageLoaderWin32.js +1 -0
  253. package/Libraries/Image/NativeImageStoreAndroid.js +1 -0
  254. package/Libraries/Image/NativeImageStoreIOS.js +1 -0
  255. package/Libraries/Image/TextInlineImageNativeComponent.js +4 -3
  256. package/Libraries/Image/nativeImageSource.js +2 -2
  257. package/Libraries/Image/resolveAssetSource.js +5 -5
  258. package/Libraries/Inspector/BorderBox.js +1 -1
  259. package/Libraries/Inspector/BoxInspector.js +3 -4
  260. package/Libraries/Inspector/DevtoolsOverlay.js +213 -0
  261. package/Libraries/Inspector/ElementBox.js +4 -5
  262. package/Libraries/Inspector/ElementProperties.js +10 -11
  263. package/Libraries/Inspector/Inspector.js +22 -108
  264. package/Libraries/Inspector/Inspector.win32.js +23 -109
  265. package/Libraries/Inspector/InspectorOverlay.js +5 -5
  266. package/Libraries/Inspector/InspectorOverlay.win32.js +5 -5
  267. package/Libraries/Inspector/InspectorPanel.js +12 -10
  268. package/Libraries/Inspector/NetworkOverlay.js +7 -3
  269. package/Libraries/Inspector/PerformanceOverlay.js +3 -3
  270. package/Libraries/Inspector/StyleInspector.js +2 -2
  271. package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +71 -0
  272. package/Libraries/Interaction/BridgeSpyStallHandler.js +1 -1
  273. package/Libraries/Interaction/InteractionManager.d.ts +74 -0
  274. package/Libraries/Interaction/InteractionManager.js +8 -8
  275. package/Libraries/Interaction/NativeFrameRateLogger.js +1 -0
  276. package/Libraries/Interaction/PanResponder.d.ts +202 -0
  277. package/Libraries/Interaction/PanResponder.flow.js +257 -0
  278. package/Libraries/Interaction/PanResponder.js +4 -3
  279. package/Libraries/JSInspector/JSInspector.js +0 -3
  280. package/Libraries/JSInspector/NetworkAgent.js +3 -3
  281. package/Libraries/LayoutAnimation/LayoutAnimation.d.ts +84 -0
  282. package/Libraries/LayoutAnimation/LayoutAnimation.js +4 -3
  283. package/Libraries/Linking/Linking.d.ts +61 -0
  284. package/Libraries/Linking/Linking.js +3 -2
  285. package/Libraries/Linking/NativeIntentAndroid.js +1 -0
  286. package/Libraries/Linking/NativeLinkingManager.js +1 -0
  287. package/Libraries/Lists/CellRenderMask.js +13 -3
  288. package/Libraries/Lists/ChildListCollection.js +72 -0
  289. package/Libraries/Lists/FillRateHelper.js +28 -17
  290. package/Libraries/Lists/FlatList.d.ts +292 -0
  291. package/Libraries/Lists/FlatList.js +70 -70
  292. package/Libraries/Lists/SectionList.d.ts +300 -0
  293. package/Libraries/Lists/SectionList.js +5 -5
  294. package/Libraries/Lists/SectionListModern.js +6 -6
  295. package/Libraries/Lists/StateSafePureComponent.js +85 -0
  296. package/Libraries/Lists/ViewabilityHelper.js +33 -12
  297. package/Libraries/Lists/VirtualizeUtils.js +17 -13
  298. package/Libraries/Lists/VirtualizedList.d.ts +317 -0
  299. package/Libraries/Lists/VirtualizedList.js +548 -890
  300. package/Libraries/Lists/VirtualizedListCellRenderer.js +259 -0
  301. package/Libraries/Lists/VirtualizedListContext.js +7 -48
  302. package/Libraries/Lists/VirtualizedListProps.js +279 -0
  303. package/Libraries/Lists/VirtualizedSectionList.js +6 -3
  304. package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
  305. package/Libraries/LogBox/Data/LogBoxData.js +9 -8
  306. package/Libraries/LogBox/Data/LogBoxLog.js +5 -5
  307. package/Libraries/LogBox/Data/LogBoxSymbolication.js +4 -4
  308. package/Libraries/LogBox/Data/parseLogBoxLog.js +5 -3
  309. package/Libraries/LogBox/LogBox.d.ts +28 -0
  310. package/Libraries/LogBox/LogBox.js +11 -11
  311. package/Libraries/LogBox/LogBoxInspectorContainer.js +5 -3
  312. package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
  313. package/Libraries/LogBox/UI/AnsiHighlight.js +5 -3
  314. package/Libraries/LogBox/UI/LogBoxButton.js +6 -5
  315. package/Libraries/LogBox/UI/LogBoxInspector.js +6 -6
  316. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +9 -8
  317. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +3 -3
  318. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +7 -6
  319. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +6 -5
  320. package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +6 -5
  321. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +7 -6
  322. package/Libraries/LogBox/UI/LogBoxInspectorSection.js +2 -2
  323. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +3 -3
  324. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +5 -5
  325. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +5 -5
  326. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +5 -5
  327. package/Libraries/LogBox/UI/LogBoxMessage.js +3 -3
  328. package/Libraries/LogBox/UI/LogBoxNotification.js +6 -5
  329. package/Libraries/Modal/Modal.d.ts +104 -0
  330. package/Libraries/Modal/Modal.js +14 -14
  331. package/Libraries/Modal/NativeModalManager.js +1 -0
  332. package/Libraries/Modal/RCTModalHostViewNativeComponent.js +3 -3
  333. package/Libraries/NativeComponent/BaseViewConfig.android.js +27 -2
  334. package/Libraries/NativeComponent/BaseViewConfig.ios.js +8 -3
  335. package/Libraries/NativeComponent/BaseViewConfig.win32.js +8 -3
  336. package/Libraries/NativeComponent/NativeComponentRegistry.js +5 -4
  337. package/Libraries/NativeComponent/PlatformBaseViewConfig.js +1 -0
  338. package/Libraries/NativeComponent/StaticViewConfigValidator.js +1 -1
  339. package/Libraries/NativeComponent/ViewConfig.js +1 -0
  340. package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +1 -0
  341. package/Libraries/NativeModules/specs/NativeDevMenu.js +1 -0
  342. package/Libraries/NativeModules/specs/NativeDevSettings.js +1 -0
  343. package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +1 -0
  344. package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +1 -0
  345. package/Libraries/NativeModules/specs/NativeLogBox.js +3 -2
  346. package/Libraries/NativeModules/specs/NativeRedBox.js +1 -0
  347. package/Libraries/NativeModules/specs/NativeSourceCode.js +1 -0
  348. package/Libraries/Network/NativeNetworkingAndroid.js +1 -0
  349. package/Libraries/Network/NativeNetworkingIOS.js +1 -0
  350. package/Libraries/Network/RCTNetworking.android.js +4 -3
  351. package/Libraries/Network/RCTNetworking.ios.js +3 -2
  352. package/Libraries/Network/RCTNetworking.win32.js +1 -0
  353. package/Libraries/Network/convertRequestBody.js +1 -2
  354. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -1
  355. package/Libraries/NewAppScreen/components/Header.js +6 -2
  356. package/Libraries/NewAppScreen/components/HermesBadge.js +6 -2
  357. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +8 -9
  358. package/Libraries/NewAppScreen/components/ReloadInstructions.js +4 -1
  359. package/Libraries/NewAppScreen/index.js +1 -1
  360. package/Libraries/Performance/NativeJSCSamplingProfiler.js +1 -0
  361. package/Libraries/Performance/QuickPerformanceLogger.js +34 -10
  362. package/Libraries/Performance/Systrace.d.ts +66 -0
  363. package/Libraries/Performance/Systrace.js +110 -195
  364. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  365. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +115 -0
  366. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +5 -4
  367. package/Libraries/Pressability/Pressability.js +12 -10
  368. package/Libraries/Pressability/Pressability.win32.js +9 -7
  369. package/Libraries/Pressability/PressabilityDebug.js +2 -2
  370. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
  371. package/Libraries/PushNotificationIOS/PushNotificationIOS.d.ts +275 -0
  372. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +19 -14
  373. package/Libraries/ReactNative/AppContainer.js +17 -7
  374. package/Libraries/ReactNative/AppRegistry.d.ts +68 -0
  375. package/Libraries/ReactNative/AppRegistry.js +11 -14
  376. package/Libraries/ReactNative/BridgelessUIManager.js +4 -3
  377. package/Libraries/ReactNative/FabricUIManager.js +3 -3
  378. package/Libraries/ReactNative/I18nManager.d.ts +25 -0
  379. package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +1 -0
  380. package/Libraries/ReactNative/NativeI18nManager.js +1 -0
  381. package/Libraries/ReactNative/NativeUIManager.js +1 -0
  382. package/Libraries/ReactNative/PaperUIManager.js +2 -2
  383. package/Libraries/ReactNative/PaperUIManager.win32.js +1 -1
  384. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +9 -0
  385. package/Libraries/ReactNative/RendererImplementation.js +112 -0
  386. package/Libraries/ReactNative/RendererProxy.d.ts +20 -0
  387. package/Libraries/ReactNative/RendererProxy.js +26 -0
  388. package/Libraries/ReactNative/RootTag.js +0 -1
  389. package/Libraries/ReactNative/UIManager.d.ts +157 -0
  390. package/Libraries/ReactNative/UIManager.js +1 -1
  391. package/Libraries/ReactNative/getCachedComponentWithDebugName.js +1 -0
  392. package/Libraries/ReactNative/renderApplication.js +38 -20
  393. package/Libraries/ReactNative/requireNativeComponent.d.ts +23 -0
  394. package/Libraries/ReactNative/requireNativeComponent.js +2 -2
  395. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +10 -9
  396. package/Libraries/Renderer/implementations/ReactFabric-dev.js +312 -217
  397. package/Libraries/Renderer/implementations/ReactFabric-prod.js +212 -177
  398. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +248 -213
  399. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +311 -218
  400. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +226 -196
  401. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +262 -232
  402. package/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +149 -0
  403. package/Libraries/Renderer/shims/ReactFabric.js +2 -2
  404. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  405. package/Libraries/Renderer/shims/ReactNative.js +2 -2
  406. package/Libraries/Renderer/shims/ReactNativeTypes.d.ts +141 -0
  407. package/Libraries/Renderer/shims/ReactNativeTypes.js +23 -22
  408. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +8 -8
  409. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  410. package/Libraries/Settings/NativeSettingsManager.js +1 -0
  411. package/Libraries/Settings/Settings.d.ts +18 -0
  412. package/Libraries/Share/NativeShareModule.js +1 -0
  413. package/Libraries/Share/Share.d.ts +80 -0
  414. package/Libraries/Share/Share.js +7 -5
  415. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +1 -1
  416. package/Libraries/StyleSheet/PlatformColorValueTypes.d.ts +18 -0
  417. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
  418. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.d.ts +25 -0
  419. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -0
  420. package/Libraries/StyleSheet/StyleSheet.d.ts +156 -0
  421. package/Libraries/StyleSheet/StyleSheet.js +15 -11
  422. package/Libraries/StyleSheet/StyleSheet.win32.js +16 -12
  423. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +332 -0
  424. package/Libraries/StyleSheet/StyleSheetTypes.js +101 -24
  425. package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +2 -2
  426. package/Libraries/StyleSheet/normalizeColor.js +3 -3
  427. package/Libraries/StyleSheet/private/_TransformStyle.js +26 -24
  428. package/Libraries/StyleSheet/processAspectRatio.js +53 -0
  429. package/Libraries/StyleSheet/processColor.d.ts +16 -0
  430. package/Libraries/StyleSheet/processColor.js +3 -4
  431. package/Libraries/StyleSheet/processColorArray.js +1 -0
  432. package/Libraries/StyleSheet/processFontVariant.js +30 -0
  433. package/Libraries/StyleSheet/processTransform.js +114 -105
  434. package/Libraries/StyleSheet/splitLayoutProps.js +5 -0
  435. package/Libraries/Text/Text.d.ts +209 -0
  436. package/Libraries/Text/Text.js +94 -12
  437. package/Libraries/Text/TextNativeComponent.js +49 -41
  438. package/Libraries/Text/TextNativeComponent.win32.js +67 -48
  439. package/Libraries/Text/TextProps.js +64 -7
  440. package/Libraries/{Components/MaskedView/MaskedViewIOS.win32.js → TurboModule/RCTExport.d.ts} +3 -4
  441. package/Libraries/TurboModule/TurboModuleRegistry.d.ts +15 -0
  442. package/Libraries/TurboModule/TurboModuleRegistry.js +3 -1
  443. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +1 -0
  444. package/Libraries/Types/CoreEventTypes.d.ts +263 -0
  445. package/Libraries/Types/CoreEventTypes.js +2 -1
  446. package/Libraries/Types/CoreEventTypes.win32.js +2 -1
  447. package/Libraries/Utilities/AcessibilityMapping.js +154 -0
  448. package/Libraries/Utilities/Appearance.d.ts +43 -0
  449. package/Libraries/Utilities/Appearance.js +3 -3
  450. package/Libraries/Utilities/BackHandler.android.js +3 -5
  451. package/Libraries/Utilities/BackHandler.d.ts +38 -0
  452. package/Libraries/Utilities/BackHandler.win32.js +3 -5
  453. package/Libraries/Utilities/DevSettings.d.ts +32 -0
  454. package/Libraries/Utilities/DevSettings.js +4 -2
  455. package/Libraries/Utilities/Dimensions.d.ts +79 -0
  456. package/Libraries/Utilities/Dimensions.js +2 -2
  457. package/Libraries/Utilities/Dimensions.win32.js +2 -2
  458. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -1
  459. package/Libraries/Utilities/HMRClient.js +23 -8
  460. package/Libraries/Utilities/LoadingView.ios.js +1 -1
  461. package/Libraries/Utilities/NativeAppearance.js +1 -0
  462. package/Libraries/Utilities/NativeDevLoadingView.js +1 -0
  463. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +1 -0
  464. package/Libraries/Utilities/NativeDeviceInfo.js +1 -0
  465. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +1 -0
  466. package/Libraries/Utilities/NativePlatformConstantsIOS.js +1 -0
  467. package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -0
  468. package/Libraries/Utilities/PerformanceLoggerContext.js +3 -2
  469. package/Libraries/Utilities/PixelRatio.d.ts +64 -0
  470. package/Libraries/Utilities/Platform.android.js +11 -5
  471. package/Libraries/Utilities/Platform.d.ts +102 -0
  472. package/Libraries/Utilities/Platform.ios.js +12 -5
  473. package/Libraries/Utilities/Platform.win32.js +11 -5
  474. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  475. package/Libraries/Utilities/ReactNativeTestTools.js +9 -15
  476. package/Libraries/Utilities/codegenNativeCommands.js +1 -10
  477. package/Libraries/Utilities/codegenNativeComponent.js +4 -1
  478. package/Libraries/Utilities/createPerformanceLogger.js +7 -8
  479. package/Libraries/Utilities/differ/deepDiffer.js +1 -1
  480. package/Libraries/Utilities/groupByEveryN.js +1 -1
  481. package/Libraries/Utilities/stringifySafe.js +3 -1
  482. package/Libraries/Utilities/useColorScheme.js +3 -2
  483. package/Libraries/Utilities/useRefEffect.js +1 -1
  484. package/Libraries/Vibration/NativeVibration.js +1 -0
  485. package/Libraries/Vibration/Vibration.d.ts +43 -0
  486. package/Libraries/Vibration/Vibration.js +1 -0
  487. package/Libraries/WebPerformance/NativePerformanceObserver.js +41 -0
  488. package/Libraries/WebPerformance/PerformanceObserver.js +223 -0
  489. package/Libraries/WebSocket/NativeWebSocketModule.js +1 -0
  490. package/Libraries/WebSocket/WebSocket.js +11 -3
  491. package/Libraries/WebSocket/WebSocketInterceptor.js +1 -1
  492. package/Libraries/YellowBox/YellowBoxDeprecated.d.ts +19 -0
  493. package/Libraries/YellowBox/YellowBoxDeprecated.js +2 -3
  494. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -1
  495. package/Libraries/__tests__/ButtonWin32-test.js +16 -0
  496. package/Libraries/platform-types.d.ts +25 -0
  497. package/Libraries/vendor/core/ErrorUtils.d.ts +15 -0
  498. package/Libraries/vendor/emitter/EventEmitter.d.ts +164 -0
  499. package/babel.config.js +3 -0
  500. package/flow/jest.js +2 -2
  501. package/flow-typed/npm/{react-dom_v16.x.x.js → react-dom_v17.x.x.js} +58 -31
  502. package/flow-typed/npm/yargs_v17.x.x.js +341 -0
  503. package/index.js +89 -55
  504. package/index.win32.js +89 -55
  505. package/interface.js +8 -0
  506. package/jest/react-native-env.js +18 -0
  507. package/jest/renderer.js +2 -2
  508. package/jest/setup.js +7 -9
  509. package/jest.config.js +9 -2
  510. package/overrides.json +40 -101
  511. package/package.json +34 -33
  512. package/src/Libraries/Components/TextInput/TextInput.win32.tsx +2 -1
  513. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  514. package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +2 -1
  515. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  516. package/src/Libraries/Components/View/ViewWin32.Props.ts +10 -1
  517. package/src/Libraries/__tests__/__snapshots__/ButtonWin32-test.js.snap +22 -0
  518. package/src/Libraries/platform-types.d.ts +25 -0
  519. package/types/index.d.ts +215 -0
  520. package/IntegrationTests/AsyncStorageTest.js +0 -261
  521. package/Libraries/Components/MaskedView/MaskedViewIOS.ios.js +0 -93
  522. package/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js +0 -21
  523. package/Libraries/Core/setUpSystrace.js +0 -21
  524. package/Libraries/Image/ImagePickerIOS.js +0 -103
  525. package/Libraries/Image/NativeImagePickerIOS.js +0 -38
  526. package/Libraries/Lists/VirtualizedList.win32.js +0 -9
  527. package/Libraries/Lists/__tests__/CellRenderMask-test.js +0 -179
  528. package/Libraries/Lists/__tests__/FillRateHelper-test.js +0 -120
  529. package/Libraries/Lists/__tests__/FlatList-test.js +0 -155
  530. package/Libraries/Lists/__tests__/SectionList-test.js +0 -109
  531. package/Libraries/Lists/__tests__/ViewabilityHelper-test.js +0 -440
  532. package/Libraries/Lists/__tests__/VirtualizeUtils-test.js +0 -91
  533. package/Libraries/Lists/__tests__/VirtualizedList-test.js +0 -1587
  534. package/Libraries/Lists/__tests__/VirtualizedSectionList-test.js +0 -269
  535. package/Libraries/Storage/AsyncStorage.js +0 -385
  536. package/Libraries/Storage/NativeAsyncLocalStorage.js +0 -44
  537. package/Libraries/Storage/NativeAsyncSQLiteDBStorage.js +0 -44
  538. package/Libraries/Utilities/JSDevSupportModule.js +0 -37
  539. package/Libraries/Utilities/NativeJSDevSupport.js +0 -23
  540. package/rntypes/BatchedBridge.d.ts +0 -23
  541. package/rntypes/Devtools.d.ts +0 -20
  542. package/rntypes/LaunchScreen.d.ts +0 -9
  543. package/rntypes/globals.d.ts +0 -497
  544. package/rntypes/index.d.ts +0 -9754
  545. package/rntypes/legacy-properties.d.ts +0 -238
  546. package/src/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +0 -427
  547. package/src/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +0 -391
  548. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +0 -4565
  549. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +0 -1153
  550. package/src/rntypes/BatchedBridge.d.ts +0 -23
  551. package/src/rntypes/Devtools.d.ts +0 -20
  552. package/src/rntypes/LaunchScreen.d.ts +0 -9
  553. package/src/rntypes/globals.d.ts +0 -497
  554. package/src/rntypes/index.d.ts +0 -9754
  555. package/src/rntypes/legacy-properties.d.ts +0 -238
  556. package/src/typings-index.ts +0 -37
  557. package/typings-index.d.ts +0 -23
  558. package/typings-index.js +0 -47
  559. package/typings-index.js.map +0 -1
@@ -11,15 +11,32 @@
11
11
  import type {ScrollResponderType} from '../Components/ScrollView/ScrollView';
12
12
  import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
13
13
  import type {LayoutEvent, ScrollEvent} from '../Types/CoreEventTypes';
14
+ import type {ViewToken} from './ViewabilityHelper';
14
15
  import type {
15
- ViewabilityConfig,
16
- ViewabilityConfigCallbackPair,
17
- ViewToken,
18
- } from './ViewabilityHelper';
19
-
16
+ FrameMetricProps,
17
+ Item,
18
+ Props,
19
+ RenderItemProps,
20
+ RenderItemType,
21
+ Separators,
22
+ } from './VirtualizedListProps';
23
+
24
+ import RefreshControl from '../Components/RefreshControl/RefreshControl';
25
+ import ScrollView from '../Components/ScrollView/ScrollView';
26
+ import View from '../Components/View/View';
27
+ import Batchinator from '../Interaction/Batchinator';
28
+ import {findNodeHandle} from '../ReactNative/RendererProxy';
29
+ import flattenStyle from '../StyleSheet/flattenStyle';
30
+ import StyleSheet from '../StyleSheet/StyleSheet';
31
+ import clamp from '../Utilities/clamp';
32
+ import infoLog from '../Utilities/infoLog';
33
+ import {CellRenderMask} from './CellRenderMask';
34
+ import ChildListCollection from './ChildListCollection';
35
+ import FillRateHelper from './FillRateHelper';
36
+ import StateSafePureComponent from './StateSafePureComponent';
37
+ import ViewabilityHelper from './ViewabilityHelper';
38
+ import CellRenderer from './VirtualizedListCellRenderer';
20
39
  import {
21
- type ChildListState,
22
- type ListDebugInfo,
23
40
  VirtualizedListCellContextProvider,
24
41
  VirtualizedListContext,
25
42
  VirtualizedListContextProvider,
@@ -28,41 +45,15 @@ import {
28
45
  computeWindowedRenderLimits,
29
46
  keyExtractor as defaultKeyExtractor,
30
47
  } from './VirtualizeUtils';
48
+ import invariant from 'invariant';
31
49
  import * as React from 'react';
32
50
 
33
- const RefreshControl = require('../Components/RefreshControl/RefreshControl');
34
- const ScrollView = require('../Components/ScrollView/ScrollView');
35
- const View = require('../Components/View/View');
36
- const Batchinator = require('../Interaction/Batchinator');
37
- const ReactNative = require('../Renderer/shims/ReactNative');
38
- const flattenStyle = require('../StyleSheet/flattenStyle');
39
- const StyleSheet = require('../StyleSheet/StyleSheet');
40
- const infoLog = require('../Utilities/infoLog');
41
- const FillRateHelper = require('./FillRateHelper');
42
- const ViewabilityHelper = require('./ViewabilityHelper');
43
- const invariant = require('invariant');
51
+ export type {RenderItemProps, RenderItemType, Separators};
44
52
 
45
53
  const ON_END_REACHED_EPSILON = 0.001;
46
54
 
47
- type Item = any;
48
-
49
- export type Separators = {
50
- highlight: () => void,
51
- unhighlight: () => void,
52
- updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
53
- ...
54
- };
55
-
56
- export type RenderItemProps<ItemT> = {
57
- item: ItemT,
58
- index: number,
59
- separators: Separators,
60
- ...
61
- };
62
-
63
- export type RenderItemType<ItemT> = (
64
- info: RenderItemProps<ItemT>,
65
- ) => React.Node;
55
+ let _usedIndexForKey = false;
56
+ let _keylessItemComponentName: string = '';
66
57
 
67
58
  type ViewabilityHelperCallbackTuple = {
68
59
  viewabilityHelper: ViewabilityHelper,
@@ -74,246 +65,9 @@ type ViewabilityHelperCallbackTuple = {
74
65
  ...
75
66
  };
76
67
 
77
- type RequiredProps = {|
78
- /**
79
- * The default accessor functions assume this is an Array<{key: string} | {id: string}> but you can override
80
- * getItem, getItemCount, and keyExtractor to handle any type of index-based data.
81
- */
82
- data?: any,
83
- /**
84
- * A generic accessor for extracting an item from any sort of data blob.
85
- */
86
- getItem: (data: any, index: number) => ?Item,
87
- /**
88
- * Determines how many items are in the data blob.
89
- */
90
- getItemCount: (data: any) => number,
91
- |};
92
- type OptionalProps = {|
93
- renderItem?: ?RenderItemType<Item>,
94
- /**
95
- * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
96
- * implementation, but with a significant perf hit.
97
- */
98
- debug?: ?boolean,
99
- /**
100
- * DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
101
- * unmounts react instances that are outside of the render window. You should only need to disable
102
- * this for debugging purposes. Defaults to false.
103
- */
104
- disableVirtualization?: ?boolean,
105
- /**
106
- * A marker property for telling the list to re-render (since it implements `PureComponent`). If
107
- * any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
108
- * `data` prop, stick it here and treat it immutably.
109
- */
110
- extraData?: any,
111
- // e.g. height, y
112
- getItemLayout?: (
113
- data: any,
114
- index: number,
115
- ) => {
116
- length: number,
117
- offset: number,
118
- index: number,
119
- ...
120
- },
121
- horizontal?: ?boolean,
122
- /**
123
- * How many items to render in the initial batch. This should be enough to fill the screen but not
124
- * much more. Note these items will never be unmounted as part of the windowed rendering in order
125
- * to improve perceived performance of scroll-to-top actions.
126
- */
127
- initialNumToRender?: ?number,
128
- /**
129
- * Instead of starting at the top with the first item, start at `initialScrollIndex`. This
130
- * disables the "scroll to top" optimization that keeps the first `initialNumToRender` items
131
- * always rendered and immediately renders the items starting at this initial index. Requires
132
- * `getItemLayout` to be implemented.
133
- */
134
- initialScrollIndex?: ?number,
135
- /**
136
- * Reverses the direction of scroll. Uses scale transforms of -1.
137
- */
138
- inverted?: ?boolean,
139
- keyExtractor?: ?(item: Item, index: number) => string,
140
- /**
141
- * Each cell is rendered using this element. Can be a React Component Class,
142
- * or a render function. Defaults to using View.
143
- */
144
- CellRendererComponent?: ?React.ComponentType<any>,
145
- /**
146
- * Rendered in between each item, but not at the top or bottom. By default, `highlighted` and
147
- * `leadingItem` props are provided. `renderItem` provides `separators.highlight`/`unhighlight`
148
- * which will update the `highlighted` prop, but you can also add custom props with
149
- * `separators.updateProps`.
150
- */
151
- ItemSeparatorComponent?: ?React.ComponentType<any>,
152
- /**
153
- * Takes an item from `data` and renders it into the list. Example usage:
154
- *
155
- * <FlatList
156
- * ItemSeparatorComponent={Platform.OS !== 'android' && ({highlighted}) => (
157
- * <View style={[style.separator, highlighted && {marginLeft: 0}]} />
158
- * )}
159
- * data={[{title: 'Title Text', key: 'item1'}]}
160
- * ListItemComponent={({item, separators}) => (
161
- * <TouchableHighlight
162
- * onPress={() => this._onPress(item)}
163
- * onShowUnderlay={separators.highlight}
164
- * onHideUnderlay={separators.unhighlight}>
165
- * <View style={{backgroundColor: 'white'}}>
166
- * <Text>{item.title}</Text>
167
- * </View>
168
- * </TouchableHighlight>
169
- * )}
170
- * />
171
- *
172
- * Provides additional metadata like `index` if you need it, as well as a more generic
173
- * `separators.updateProps` function which let's you set whatever props you want to change the
174
- * rendering of either the leading separator or trailing separator in case the more common
175
- * `highlight` and `unhighlight` (which set the `highlighted: boolean` prop) are insufficient for
176
- * your use-case.
177
- */
178
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
179
- /**
180
- * Rendered when the list is empty. Can be a React Component Class, a render function, or
181
- * a rendered element.
182
- */
183
- ListEmptyComponent?: ?(React.ComponentType<any> | React.Element<any>),
184
- /**
185
- * Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
186
- * a rendered element.
187
- */
188
- ListFooterComponent?: ?(React.ComponentType<any> | React.Element<any>),
189
- /**
190
- * Styling for internal View for ListFooterComponent
191
- */
192
- ListFooterComponentStyle?: ViewStyleProp,
193
- /**
194
- * Rendered at the top of all the items. Can be a React Component Class, a render function, or
195
- * a rendered element.
196
- */
197
- ListHeaderComponent?: ?(React.ComponentType<any> | React.Element<any>),
198
- /**
199
- * Styling for internal View for ListHeaderComponent
200
- */
201
- ListHeaderComponentStyle?: ViewStyleProp,
202
- /**
203
- * A unique identifier for this list. If there are multiple VirtualizedLists at the same level of
204
- * nesting within another VirtualizedList, this key is necessary for virtualization to
205
- * work properly.
206
- */
207
- listKey?: string,
208
- /**
209
- * The maximum number of items to render in each incremental render batch. The more rendered at
210
- * once, the better the fill rate, but responsiveness may suffer because rendering content may
211
- * interfere with responding to button taps or other interactions.
212
- */
213
- maxToRenderPerBatch?: ?number,
214
- /**
215
- * Called once when the scroll position gets within `onEndReachedThreshold` of the rendered
216
- * content.
217
- */
218
- onEndReached?: ?(info: {distanceFromEnd: number, ...}) => void,
219
- /**
220
- * How far from the end (in units of visible length of the list) the bottom edge of the
221
- * list must be from the end of the content to trigger the `onEndReached` callback.
222
- * Thus a value of 0.5 will trigger `onEndReached` when the end of the content is
223
- * within half the visible length of the list. A value of 0 will not trigger until scrolling
224
- * to the very end of the list.
225
- */
226
- onEndReachedThreshold?: ?number,
227
- /**
228
- * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
229
- * sure to also set the `refreshing` prop correctly.
230
- */
231
- onRefresh?: ?() => void,
232
- /**
233
- * Used to handle failures when scrolling to an index that has not been measured yet. Recommended
234
- * action is to either compute your own offset and `scrollTo` it, or scroll as far as possible and
235
- * then try again after more items have been rendered.
236
- */
237
- onScrollToIndexFailed?: ?(info: {
238
- index: number,
239
- highestMeasuredFrameIndex: number,
240
- averageItemLength: number,
241
- ...
242
- }) => void,
243
- /**
244
- * Called when the viewability of rows changes, as defined by the
245
- * `viewabilityConfig` prop.
246
- */
247
- onViewableItemsChanged?: ?(info: {
248
- viewableItems: Array<ViewToken>,
249
- changed: Array<ViewToken>,
250
- ...
251
- }) => void,
252
- persistentScrollbar?: ?boolean,
253
- /**
254
- * Set this when offset is needed for the loading indicator to show correctly.
255
- */
256
- progressViewOffset?: number,
257
- /**
258
- * A custom refresh control element. When set, it overrides the default
259
- * <RefreshControl> component built internally. The onRefresh and refreshing
260
- * props are also ignored. Only works for vertical VirtualizedList.
261
- */
262
- refreshControl?: ?React.Element<any>,
263
- /**
264
- * Set this true while waiting for new data from a refresh.
265
- */
266
- refreshing?: ?boolean,
267
- /**
268
- * Note: may have bugs (missing content) in some circumstances - use at your own risk.
269
- *
270
- * This may improve scroll performance for large lists.
271
- */
272
- removeClippedSubviews?: boolean,
273
- /**
274
- * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
275
- */
276
- renderScrollComponent?: (props: Object) => React.Element<any>,
277
- /**
278
- * Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
279
- * screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
280
- */
281
- updateCellsBatchingPeriod?: ?number,
282
- /**
283
- * See `ViewabilityHelper` for flow type and further documentation.
284
- */
285
- viewabilityConfig?: ViewabilityConfig,
286
- /**
287
- * List of ViewabilityConfig/onViewableItemsChanged pairs. A specific onViewableItemsChanged
288
- * will be called when its corresponding ViewabilityConfig's conditions are met.
289
- */
290
- viewabilityConfigCallbackPairs?: Array<ViewabilityConfigCallbackPair>,
291
- /**
292
- * Determines the maximum number of items rendered outside of the visible area, in units of
293
- * visible lengths. So if your list fills the screen, then `windowSize={21}` (the default) will
294
- * render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
295
- * this number will reduce memory consumption and may improve performance, but will increase the
296
- * chance that fast scrolling may reveal momentary blank areas of unrendered content.
297
- */
298
- windowSize?: ?number,
299
- /**
300
- * The legacy implementation is no longer supported.
301
- */
302
- legacyImplementation?: empty,
303
- |};
304
-
305
- type Props = {|
306
- ...React.ElementConfig<typeof ScrollView>,
307
- ...RequiredProps,
308
- ...OptionalProps,
309
- |};
310
-
311
- let _usedIndexForKey = false;
312
- let _keylessItemComponentName: string = '';
313
-
314
68
  type State = {
315
- first: number,
316
- last: number,
69
+ renderMask: CellRenderMask,
70
+ cellsAroundViewport: {first: number, last: number},
317
71
  };
318
72
 
319
73
  /**
@@ -351,6 +105,19 @@ function windowSizeOrDefault(windowSize: ?number) {
351
105
  return windowSize ?? 21;
352
106
  }
353
107
 
108
+ function findLastWhere<T>(
109
+ arr: $ReadOnlyArray<T>,
110
+ predicate: (element: T) => boolean,
111
+ ): T | null {
112
+ for (let i = arr.length - 1; i >= 0; i--) {
113
+ if (predicate(arr[i])) {
114
+ return arr[i];
115
+ }
116
+ }
117
+
118
+ return null;
119
+ }
120
+
354
121
  /**
355
122
  * Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist)
356
123
  * and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better
@@ -380,14 +147,17 @@ function windowSizeOrDefault(windowSize: ?number) {
380
147
  * - As an effort to remove defaultProps, use helper functions when referencing certain props
381
148
  *
382
149
  */
383
- class VirtualizedList extends React.PureComponent<Props, State> {
150
+ export default class VirtualizedList extends StateSafePureComponent<
151
+ Props,
152
+ State,
153
+ > {
384
154
  static contextType: typeof VirtualizedListContext = VirtualizedListContext;
385
155
 
386
156
  // scrollToEnd may be janky without getItemLayout prop
387
157
  scrollToEnd(params?: ?{animated?: ?boolean, ...}) {
388
158
  const animated = params ? params.animated : true;
389
159
  const veryLast = this.props.getItemCount(this.props.data) - 1;
390
- const frame = this.__getFrameMetricsApprox(veryLast);
160
+ const frame = this.__getFrameMetricsApprox(veryLast, this.props);
391
161
  const offset = Math.max(
392
162
  0,
393
163
  frame.offset +
@@ -423,7 +193,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
423
193
  viewOffset?: number,
424
194
  viewPosition?: number,
425
195
  ...
426
- }) {
196
+ }): $FlowFixMe {
427
197
  const {
428
198
  data,
429
199
  horizontal,
@@ -461,11 +231,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
461
231
  });
462
232
  return;
463
233
  }
464
- const frame = this.__getFrameMetricsApprox(index);
234
+ const frame = this.__getFrameMetricsApprox(Math.floor(index), this.props);
465
235
  const offset =
466
236
  Math.max(
467
237
  0,
468
- frame.offset -
238
+ this._getOffsetApprox(index, this.props) -
469
239
  (viewPosition || 0) *
470
240
  (this._scrollMetrics.visibleLength - frame.length),
471
241
  ) - (viewOffset || 0);
@@ -542,12 +312,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
542
312
 
543
313
  recordInteraction() {
544
314
  this._nestedChildLists.forEach(childList => {
545
- childList.ref && childList.ref.recordInteraction();
315
+ childList.recordInteraction();
546
316
  });
547
317
  this._viewabilityTuples.forEach(t => {
548
318
  t.viewabilityHelper.recordInteraction();
549
319
  });
550
- this._updateViewableItems(this.props.data);
320
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
551
321
  }
552
322
 
553
323
  flashScrollIndicators() {
@@ -573,7 +343,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
573
343
  if (this._scrollRef && this._scrollRef.getScrollableNode) {
574
344
  return this._scrollRef.getScrollableNode();
575
345
  } else {
576
- return ReactNative.findNodeHandle(this._scrollRef);
346
+ return findNodeHandle(this._scrollRef);
577
347
  }
578
348
  }
579
349
 
@@ -597,19 +367,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
597
367
  return this.context?.cellKey || 'rootList';
598
368
  }
599
369
 
600
- _getListKey(): string {
601
- return this.props.listKey || this._getCellKey();
602
- }
603
-
604
- _getDebugInfo(): ListDebugInfo {
605
- return {
606
- listKey: this._getListKey(),
607
- cellKey: this._getCellKey(),
608
- horizontal: horizontalOrDefault(this.props.horizontal),
609
- parent: this.context?.debugInfo,
610
- };
611
- }
612
-
370
+ // $FlowFixMe[missing-local-annot]
613
371
  _getScrollMetrics = () => {
614
372
  return this._scrollMetrics;
615
373
  };
@@ -618,6 +376,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
618
376
  return this._hasMore;
619
377
  }
620
378
 
379
+ // $FlowFixMe[missing-local-annot]
621
380
  _getOutermostParentListRef = () => {
622
381
  if (this._isNestedWithSameOrientation()) {
623
382
  return this.context.getOutermostParentListRef();
@@ -626,56 +385,20 @@ class VirtualizedList extends React.PureComponent<Props, State> {
626
385
  }
627
386
  };
628
387
 
629
- _getNestedChildState = (key: string): ?ChildListState => {
630
- const existingChildData = this._nestedChildLists.get(key);
631
- return existingChildData && existingChildData.state;
632
- };
633
-
634
388
  _registerAsNestedChild = (childList: {
635
389
  cellKey: string,
636
- key: string,
637
- ref: VirtualizedList,
638
- parentDebugInfo: ListDebugInfo,
639
- ...
640
- }): ?ChildListState => {
641
- // Register the mapping between this child key and the cellKey for its cell
642
- const childListsInCell =
643
- this._cellKeysToChildListKeys.get(childList.cellKey) || new Set();
644
- childListsInCell.add(childList.key);
645
- this._cellKeysToChildListKeys.set(childList.cellKey, childListsInCell);
646
- const existingChildData = this._nestedChildLists.get(childList.key);
647
- if (existingChildData && existingChildData.ref !== null) {
648
- console.error(
649
- 'A VirtualizedList contains a cell which itself contains ' +
650
- 'more than one VirtualizedList of the same orientation as the parent ' +
651
- 'list. You must pass a unique listKey prop to each sibling list.\n\n' +
652
- describeNestedLists({
653
- ...childList,
654
- // We're called from the child's componentDidMount, so it's safe to
655
- // read the child's props here (albeit weird).
656
- horizontal: !!childList.ref.props.horizontal,
657
- }),
658
- );
659
- }
660
- this._nestedChildLists.set(childList.key, {
661
- ref: childList.ref,
662
- state: null,
663
- });
664
-
390
+ ref: React.ElementRef<typeof VirtualizedList>,
391
+ }): void => {
392
+ this._nestedChildLists.add(childList.ref, childList.cellKey);
665
393
  if (this._hasInteracted) {
666
394
  childList.ref.recordInteraction();
667
395
  }
668
396
  };
669
397
 
670
398
  _unregisterAsNestedChild = (childList: {
671
- key: string,
672
- state: ChildListState,
673
- ...
399
+ ref: React.ElementRef<typeof VirtualizedList>,
674
400
  }): void => {
675
- this._nestedChildLists.set(childList.key, {
676
- ref: null,
677
- state: childList.state,
678
- });
401
+ this._nestedChildLists.remove(childList.ref);
679
402
  };
680
403
 
681
404
  state: State;
@@ -693,6 +416,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
693
416
  'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.',
694
417
  );
695
418
 
419
+ invariant(
420
+ props.getItemCount,
421
+ 'VirtualizedList: The "getItemCount" prop must be provided',
422
+ );
423
+
696
424
  this._fillRateHelper = new FillRateHelper(this._getFrameMetrics);
697
425
  this._updateCellsToRenderBatcher = new Batchinator(
698
426
  this._updateCellsToRender,
@@ -716,55 +444,210 @@ class VirtualizedList extends React.PureComponent<Props, State> {
716
444
  }
717
445
  }
718
446
 
719
- let initialState = {
720
- first: this.props.initialScrollIndex || 0,
447
+ invariant(
448
+ !this.context,
449
+ 'Unexpectedly saw VirtualizedListContext available in ctor',
450
+ );
451
+
452
+ const initialRenderRegion = VirtualizedList._initialRenderRegion(props);
453
+
454
+ this.state = {
455
+ cellsAroundViewport: initialRenderRegion,
456
+ renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
457
+ };
458
+ }
459
+
460
+ static _createRenderMask(
461
+ props: Props,
462
+ cellsAroundViewport: {first: number, last: number},
463
+ additionalRegions?: ?$ReadOnlyArray<{first: number, last: number}>,
464
+ ): CellRenderMask {
465
+ const itemCount = props.getItemCount(props.data);
466
+
467
+ invariant(
468
+ cellsAroundViewport.first >= 0 &&
469
+ cellsAroundViewport.last >= cellsAroundViewport.first - 1 &&
470
+ cellsAroundViewport.last < itemCount,
471
+ `Invalid cells around viewport "[${cellsAroundViewport.first}, ${cellsAroundViewport.last}]" was passed to VirtualizedList._createRenderMask`,
472
+ );
473
+
474
+ const renderMask = new CellRenderMask(itemCount);
475
+
476
+ if (itemCount > 0) {
477
+ const allRegions = [cellsAroundViewport, ...(additionalRegions ?? [])];
478
+ for (const region of allRegions) {
479
+ renderMask.addCells(region);
480
+ }
481
+
482
+ // The initially rendered cells are retained as part of the
483
+ // "scroll-to-top" optimization
484
+ if (props.initialScrollIndex == null || props.initialScrollIndex <= 0) {
485
+ const initialRegion = VirtualizedList._initialRenderRegion(props);
486
+ renderMask.addCells(initialRegion);
487
+ }
488
+
489
+ // The layout coordinates of sticker headers may be off-screen while the
490
+ // actual header is on-screen. Keep the most recent before the viewport
491
+ // rendered, even if its layout coordinates are not in viewport.
492
+ const stickyIndicesSet = new Set(props.stickyHeaderIndices);
493
+ VirtualizedList._ensureClosestStickyHeader(
494
+ props,
495
+ stickyIndicesSet,
496
+ renderMask,
497
+ cellsAroundViewport.first,
498
+ );
499
+ }
500
+
501
+ return renderMask;
502
+ }
503
+
504
+ static _initialRenderRegion(props: Props): {first: number, last: number} {
505
+ const itemCount = props.getItemCount(props.data);
506
+ const scrollIndex = Math.floor(Math.max(0, props.initialScrollIndex ?? 0));
507
+
508
+ return {
509
+ first: scrollIndex,
721
510
  last:
722
511
  Math.min(
723
- this.props.getItemCount(this.props.data),
724
- (this.props.initialScrollIndex || 0) +
725
- initialNumToRenderOrDefault(this.props.initialNumToRender),
512
+ itemCount,
513
+ scrollIndex + initialNumToRenderOrDefault(props.initialNumToRender),
726
514
  ) - 1,
727
515
  };
516
+ }
728
517
 
729
- if (this._isNestedWithSameOrientation()) {
730
- const storedState = this.context.getNestedChildState(this._getListKey());
731
- if (storedState) {
732
- initialState = storedState;
733
- this.state = storedState;
734
- this._frames = storedState.frames;
518
+ static _ensureClosestStickyHeader(
519
+ props: Props,
520
+ stickyIndicesSet: Set<number>,
521
+ renderMask: CellRenderMask,
522
+ cellIdx: number,
523
+ ) {
524
+ const stickyOffset = props.ListHeaderComponent ? 1 : 0;
525
+
526
+ for (let itemIdx = cellIdx - 1; itemIdx >= 0; itemIdx--) {
527
+ if (stickyIndicesSet.has(itemIdx + stickyOffset)) {
528
+ renderMask.addCells({first: itemIdx, last: itemIdx});
529
+ break;
735
530
  }
736
531
  }
532
+ }
533
+
534
+ _adjustCellsAroundViewport(
535
+ props: Props,
536
+ cellsAroundViewport: {first: number, last: number},
537
+ ): {first: number, last: number} {
538
+ const {data, getItemCount} = props;
539
+ const onEndReachedThreshold = onEndReachedThresholdOrDefault(
540
+ props.onEndReachedThreshold,
541
+ );
542
+ this._updateViewableItems(props, cellsAroundViewport);
543
+
544
+ const {contentLength, offset, visibleLength} = this._scrollMetrics;
545
+ const distanceFromEnd = contentLength - visibleLength - offset;
546
+
547
+ // Wait until the scroll view metrics have been set up. And until then,
548
+ // we will trust the initialNumToRender suggestion
549
+ if (visibleLength <= 0 || contentLength <= 0) {
550
+ return cellsAroundViewport.last >= getItemCount(data)
551
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
552
+ : cellsAroundViewport;
553
+ }
737
554
 
738
- this.state = initialState;
555
+ let newCellsAroundViewport: {first: number, last: number};
556
+ if (props.disableVirtualization) {
557
+ const renderAhead =
558
+ distanceFromEnd < onEndReachedThreshold * visibleLength
559
+ ? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
560
+ : 0;
561
+
562
+ newCellsAroundViewport = {
563
+ first: 0,
564
+ last: Math.min(
565
+ cellsAroundViewport.last + renderAhead,
566
+ getItemCount(data) - 1,
567
+ ),
568
+ };
569
+ } else {
570
+ // If we have a non-zero initialScrollIndex and run this before we've scrolled,
571
+ // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
572
+ // So let's wait until we've scrolled the view to the right place. And until then,
573
+ // we will trust the initialScrollIndex suggestion.
574
+
575
+ // Thus, we want to recalculate the windowed render limits if any of the following hold:
576
+ // - initialScrollIndex is undefined or is 0
577
+ // - initialScrollIndex > 0 AND scrolling is complete
578
+ // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
579
+ // where the list is shorter than the visible area)
580
+ if (
581
+ props.initialScrollIndex &&
582
+ !this._scrollMetrics.offset &&
583
+ Math.abs(distanceFromEnd) >= Number.EPSILON
584
+ ) {
585
+ return cellsAroundViewport.last >= getItemCount(data)
586
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
587
+ : cellsAroundViewport;
588
+ }
589
+
590
+ newCellsAroundViewport = computeWindowedRenderLimits(
591
+ props,
592
+ maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
593
+ windowSizeOrDefault(props.windowSize),
594
+ cellsAroundViewport,
595
+ this.__getFrameMetricsApprox,
596
+ this._scrollMetrics,
597
+ );
598
+ invariant(
599
+ newCellsAroundViewport.last < getItemCount(data),
600
+ 'computeWindowedRenderLimits() should return range in-bounds',
601
+ );
602
+ }
603
+
604
+ if (this._nestedChildLists.size() > 0) {
605
+ // If some cell in the new state has a child list in it, we should only render
606
+ // up through that item, so that we give that list a chance to render.
607
+ // Otherwise there's churn from multiple child lists mounting and un-mounting
608
+ // their items.
609
+
610
+ // Will this prevent rendering if the nested list doesn't realize the end?
611
+ const childIdx = this._findFirstChildWithMore(
612
+ newCellsAroundViewport.first,
613
+ newCellsAroundViewport.last,
614
+ );
615
+
616
+ newCellsAroundViewport.last = childIdx ?? newCellsAroundViewport.last;
617
+ }
618
+
619
+ return newCellsAroundViewport;
620
+ }
621
+
622
+ _findFirstChildWithMore(first: number, last: number): number | null {
623
+ for (let ii = first; ii <= last; ii++) {
624
+ const cellKeyForIndex = this._indicesToKeys.get(ii);
625
+ if (
626
+ cellKeyForIndex != null &&
627
+ this._nestedChildLists.anyInCell(cellKeyForIndex, childList =>
628
+ childList.hasMore(),
629
+ )
630
+ ) {
631
+ return ii;
632
+ }
633
+ }
634
+
635
+ return null;
739
636
  }
740
637
 
741
638
  componentDidMount() {
742
639
  if (this._isNestedWithSameOrientation()) {
743
640
  this.context.registerAsNestedChild({
744
- cellKey: this._getCellKey(),
745
- key: this._getListKey(),
746
641
  ref: this,
747
- // NOTE: When the child mounts (here) it's not necessarily safe to read
748
- // the parent's props. This is why we explicitly propagate debugInfo
749
- // "down" via context and "up" again via this method call on the
750
- // parent.
751
- parentDebugInfo: this.context.debugInfo,
642
+ cellKey: this.context.cellKey,
752
643
  });
753
644
  }
754
645
  }
755
646
 
756
647
  componentWillUnmount() {
757
648
  if (this._isNestedWithSameOrientation()) {
758
- this.context.unregisterAsNestedChild({
759
- key: this._getListKey(),
760
- state: {
761
- first: this.state.first,
762
- last: this.state.last,
763
- frames: this._frames,
764
- },
765
- });
649
+ this.context.unregisterAsNestedChild({ref: this});
766
650
  }
767
- this._updateViewableItems(null);
768
651
  this._updateCellsToRenderBatcher.dispose({abort: true});
769
652
  this._viewabilityTuples.forEach(tuple => {
770
653
  tuple.viewabilityHelper.dispose();
@@ -773,18 +656,21 @@ class VirtualizedList extends React.PureComponent<Props, State> {
773
656
  }
774
657
 
775
658
  static getDerivedStateFromProps(newProps: Props, prevState: State): State {
776
- const {data, getItemCount} = newProps;
777
- const maxToRenderPerBatch = maxToRenderPerBatchOrDefault(
778
- newProps.maxToRenderPerBatch,
779
- );
780
659
  // first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
781
660
  // sure we're rendering a reasonable range here.
661
+ const itemCount = newProps.getItemCount(newProps.data);
662
+ if (itemCount === prevState.renderMask.numCells()) {
663
+ return prevState;
664
+ }
665
+
666
+ const constrainedCells = VirtualizedList._constrainToItemCount(
667
+ prevState.cellsAroundViewport,
668
+ newProps,
669
+ );
670
+
782
671
  return {
783
- first: Math.max(
784
- 0,
785
- Math.min(prevState.first, getItemCount(data) - 1 - maxToRenderPerBatch),
786
- ),
787
- last: Math.max(0, Math.min(prevState.last, getItemCount(data) - 1)),
672
+ cellsAroundViewport: constrainedCells,
673
+ renderMask: VirtualizedList._createRenderMask(newProps, constrainedCells),
788
674
  };
789
675
  }
790
676
 
@@ -815,7 +701,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
815
701
  last = Math.min(end, last);
816
702
  for (let ii = first; ii <= last; ii++) {
817
703
  const item = getItem(data, ii);
818
- const key = this._keyExtractor(item, ii);
704
+ const key = this._keyExtractor(item, ii, this.props);
819
705
  this._indicesToKeys.set(ii, key);
820
706
  if (stickyIndicesFromProps.has(ii + stickyOffset)) {
821
707
  stickyHeaderIndices.push(cells.length);
@@ -837,6 +723,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
837
723
  prevCellKey={prevCellKey}
838
724
  onCellLayout={this._onCellLayout}
839
725
  onUpdateSeparators={this._onUpdateSeparators}
726
+ onCellFocusCapture={e => this._onCellFocusCapture(key)}
840
727
  onUnmount={this._onCellUnmount}
841
728
  ref={ref => {
842
729
  this._cellRefs[key] = ref;
@@ -848,6 +735,23 @@ class VirtualizedList extends React.PureComponent<Props, State> {
848
735
  }
849
736
  }
850
737
 
738
+ static _constrainToItemCount(
739
+ cells: {first: number, last: number},
740
+ props: Props,
741
+ ): {first: number, last: number} {
742
+ const itemCount = props.getItemCount(props.data);
743
+ const last = Math.min(itemCount - 1, cells.last);
744
+
745
+ const maxToRenderPerBatch = maxToRenderPerBatchOrDefault(
746
+ props.maxToRenderPerBatch,
747
+ );
748
+
749
+ return {
750
+ first: clamp(0, itemCount - 1 - maxToRenderPerBatch, cells.first),
751
+ last,
752
+ };
753
+ }
754
+
851
755
  _onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
852
756
  keys.forEach(key => {
853
757
  const ref = key != null && this._cellRefs[key];
@@ -855,10 +759,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
855
759
  });
856
760
  };
857
761
 
858
- _isVirtualizationDisabled(): boolean {
859
- return this.props.disableVirtualization || false;
860
- }
861
-
862
762
  _isNestedWithSameOrientation(): boolean {
863
763
  const nestedContext = this.context;
864
764
  return !!(
@@ -870,9 +770,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
870
770
  _getSpacerKey = (isVertical: boolean): string =>
871
771
  isVertical ? 'height' : 'width';
872
772
 
873
- _keyExtractor(item: Item, index: number) {
874
- if (this.props.keyExtractor != null) {
875
- return this.props.keyExtractor(item, index);
773
+ _keyExtractor(
774
+ item: Item,
775
+ index: number,
776
+ props: {
777
+ keyExtractor?: ?(item: Item, index: number) => string,
778
+ ...
779
+ },
780
+ // $FlowFixMe[missing-local-annot]
781
+ ) {
782
+ if (props.keyExtractor != null) {
783
+ return props.keyExtractor(item, index);
876
784
  }
877
785
 
878
786
  const key = defaultKeyExtractor(item, index);
@@ -898,15 +806,16 @@ class VirtualizedList extends React.PureComponent<Props, State> {
898
806
  const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
899
807
  this.props;
900
808
  const {data, horizontal} = this.props;
901
- const isVirtualizationDisabled = this._isVirtualizationDisabled();
902
809
  const inversionStyle = this.props.inverted
903
810
  ? horizontalOrDefault(this.props.horizontal)
904
811
  ? styles.horizontallyInverted
905
812
  : styles.verticallyInverted
906
813
  : null;
907
- const cells = [];
814
+ const cells: Array<any | React.Node> = [];
908
815
  const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
909
816
  const stickyHeaderIndices = [];
817
+
818
+ // 1. Add cell for ListHeaderComponent
910
819
  if (ListHeaderComponent) {
911
820
  if (stickyIndicesFromProps.has(0)) {
912
821
  stickyHeaderIndices.push(0);
@@ -936,103 +845,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
936
845
  </VirtualizedListCellContextProvider>,
937
846
  );
938
847
  }
848
+
849
+ // 2a. Add a cell for ListEmptyComponent if applicable
939
850
  const itemCount = this.props.getItemCount(data);
940
- if (itemCount > 0) {
941
- _usedIndexForKey = false;
942
- _keylessItemComponentName = '';
943
- const spacerKey = this._getSpacerKey(!horizontal);
944
- const lastInitialIndex = this.props.initialScrollIndex
945
- ? -1
946
- : initialNumToRenderOrDefault(this.props.initialNumToRender) - 1;
947
- const {first, last} = this.state;
948
- this._pushCells(
949
- cells,
950
- stickyHeaderIndices,
951
- stickyIndicesFromProps,
952
- 0,
953
- lastInitialIndex,
954
- inversionStyle,
955
- );
956
- const firstAfterInitial = Math.max(lastInitialIndex + 1, first);
957
- if (!isVirtualizationDisabled && first > lastInitialIndex + 1) {
958
- let insertedStickySpacer = false;
959
- if (stickyIndicesFromProps.size > 0) {
960
- const stickyOffset = ListHeaderComponent ? 1 : 0;
961
- // See if there are any sticky headers in the virtualized space that we need to render.
962
- for (let ii = firstAfterInitial - 1; ii > lastInitialIndex; ii--) {
963
- if (stickyIndicesFromProps.has(ii + stickyOffset)) {
964
- const initBlock = this.__getFrameMetricsApprox(lastInitialIndex);
965
- const stickyBlock = this.__getFrameMetricsApprox(ii);
966
- const leadSpace =
967
- stickyBlock.offset -
968
- initBlock.offset -
969
- (this.props.initialScrollIndex ? 0 : initBlock.length);
970
- cells.push(
971
- <View key="$sticky_lead" style={{[spacerKey]: leadSpace}} />,
972
- );
973
- this._pushCells(
974
- cells,
975
- stickyHeaderIndices,
976
- stickyIndicesFromProps,
977
- ii,
978
- ii,
979
- inversionStyle,
980
- );
981
- const trailSpace =
982
- this.__getFrameMetricsApprox(first).offset -
983
- (stickyBlock.offset + stickyBlock.length);
984
- cells.push(
985
- <View key="$sticky_trail" style={{[spacerKey]: trailSpace}} />,
986
- );
987
- insertedStickySpacer = true;
988
- break;
989
- }
990
- }
991
- }
992
- if (!insertedStickySpacer) {
993
- const initBlock = this.__getFrameMetricsApprox(lastInitialIndex);
994
- const firstSpace =
995
- this.__getFrameMetricsApprox(first).offset -
996
- (initBlock.offset + initBlock.length);
997
- cells.push(
998
- <View key="$lead_spacer" style={{[spacerKey]: firstSpace}} />,
999
- );
1000
- }
1001
- }
1002
- this._pushCells(
1003
- cells,
1004
- stickyHeaderIndices,
1005
- stickyIndicesFromProps,
1006
- firstAfterInitial,
1007
- last,
1008
- inversionStyle,
1009
- );
1010
- if (!this._hasWarned.keys && _usedIndexForKey) {
1011
- console.warn(
1012
- 'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
1013
- 'item or provide a custom keyExtractor.',
1014
- _keylessItemComponentName,
1015
- );
1016
- this._hasWarned.keys = true;
1017
- }
1018
- if (!isVirtualizationDisabled && last < itemCount - 1) {
1019
- const lastFrame = this.__getFrameMetricsApprox(last);
1020
- // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
1021
- // prevent the user for hyperscrolling into un-measured area because otherwise content will
1022
- // likely jump around as it renders in above the viewport.
1023
- const end = this.props.getItemLayout
1024
- ? itemCount - 1
1025
- : Math.min(itemCount - 1, this._highestMeasuredFrameIndex);
1026
- const endFrame = this.__getFrameMetricsApprox(end);
1027
- const tailSpacerLength =
1028
- endFrame.offset +
1029
- endFrame.length -
1030
- (lastFrame.offset + lastFrame.length);
1031
- cells.push(
1032
- <View key="$tail_spacer" style={{[spacerKey]: tailSpacerLength}} />,
1033
- );
1034
- }
1035
- } else if (ListEmptyComponent) {
851
+ if (itemCount === 0 && ListEmptyComponent) {
1036
852
  const element: React.Element<any> = ((React.isValidElement(
1037
853
  ListEmptyComponent,
1038
854
  ) ? (
@@ -1055,6 +871,73 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1055
871
  }),
1056
872
  );
1057
873
  }
874
+
875
+ // 2b. Add cells and spacers for each item
876
+ if (itemCount > 0) {
877
+ _usedIndexForKey = false;
878
+ _keylessItemComponentName = '';
879
+ const spacerKey = this._getSpacerKey(!horizontal);
880
+
881
+ const renderRegions = this.state.renderMask.enumerateRegions();
882
+ const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer);
883
+
884
+ for (const section of renderRegions) {
885
+ if (section.isSpacer) {
886
+ // Legacy behavior is to avoid spacers when virtualization is
887
+ // disabled (including head spacers on initial render).
888
+ if (this.props.disableVirtualization) {
889
+ continue;
890
+ }
891
+
892
+ // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
893
+ // prevent the user for hyperscrolling into un-measured area because otherwise content will
894
+ // likely jump around as it renders in above the viewport.
895
+ const isLastSpacer = section === lastSpacer;
896
+ const constrainToMeasured = isLastSpacer && !this.props.getItemLayout;
897
+ const last = constrainToMeasured
898
+ ? clamp(
899
+ section.first - 1,
900
+ section.last,
901
+ this._highestMeasuredFrameIndex,
902
+ )
903
+ : section.last;
904
+
905
+ const firstMetrics = this.__getFrameMetricsApprox(
906
+ section.first,
907
+ this.props,
908
+ );
909
+ const lastMetrics = this.__getFrameMetricsApprox(last, this.props);
910
+ const spacerSize =
911
+ lastMetrics.offset + lastMetrics.length - firstMetrics.offset;
912
+ cells.push(
913
+ <View
914
+ key={`$spacer-${section.first}`}
915
+ style={{[spacerKey]: spacerSize}}
916
+ />,
917
+ );
918
+ } else {
919
+ this._pushCells(
920
+ cells,
921
+ stickyHeaderIndices,
922
+ stickyIndicesFromProps,
923
+ section.first,
924
+ section.last,
925
+ inversionStyle,
926
+ );
927
+ }
928
+ }
929
+
930
+ if (!this._hasWarned.keys && _usedIndexForKey) {
931
+ console.warn(
932
+ 'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
933
+ 'item or provide a custom keyExtractor.',
934
+ _keylessItemComponentName,
935
+ );
936
+ this._hasWarned.keys = true;
937
+ }
938
+ }
939
+
940
+ // 3. Add cell for ListFooterComponent
1058
941
  if (ListFooterComponent) {
1059
942
  const element = React.isValidElement(ListFooterComponent) ? (
1060
943
  ListFooterComponent
@@ -1081,6 +964,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1081
964
  </VirtualizedListCellContextProvider>,
1082
965
  );
1083
966
  }
967
+
968
+ // 4. Render the ScrollView
1084
969
  const scrollProps = {
1085
970
  ...this.props,
1086
971
  onContentSizeChange: this._onContentSizeChange,
@@ -1103,8 +988,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1103
988
  : this.props.style,
1104
989
  };
1105
990
 
1106
- this._hasMore =
1107
- this.state.last < this.props.getItemCount(this.props.data) - 1;
991
+ this._hasMore = this.state.cellsAroundViewport.last < itemCount - 1;
1108
992
 
1109
993
  const innerRet = (
1110
994
  <VirtualizedListContextProvider
@@ -1113,10 +997,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1113
997
  getScrollMetrics: this._getScrollMetrics,
1114
998
  horizontal: horizontalOrDefault(this.props.horizontal),
1115
999
  getOutermostParentListRef: this._getOutermostParentListRef,
1116
- getNestedChildState: this._getNestedChildState,
1117
1000
  registerAsNestedChild: this._registerAsNestedChild,
1118
1001
  unregisterAsNestedChild: this._unregisterAsNestedChild,
1119
- debugInfo: this._getDebugInfo(),
1120
1002
  }}>
1121
1003
  {React.cloneElement(
1122
1004
  (
@@ -1140,7 +1022,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1140
1022
  !scrollContext.horizontal ===
1141
1023
  !horizontalOrDefault(this.props.horizontal) &&
1142
1024
  !this._hasWarned.nesting &&
1143
- this.context == null
1025
+ this.context == null &&
1026
+ this.props.scrollEnabled !== false
1144
1027
  ) {
1145
1028
  // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
1146
1029
  console.error(
@@ -1192,9 +1075,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1192
1075
  }
1193
1076
 
1194
1077
  _averageCellLength = 0;
1195
- // Maps a cell key to the set of keys for all outermost child lists within that cell
1196
- _cellKeysToChildListKeys: Map<string, Set<string>> = new Map();
1197
- _cellRefs: {[string]: null | CellRenderer} = {};
1078
+ _cellRefs: {[string]: null | CellRenderer<any>} = {};
1198
1079
  _fillRateHelper: FillRateHelper;
1199
1080
  _frames: {
1200
1081
  [string]: {
@@ -1214,16 +1095,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1214
1095
  _hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
1215
1096
  _highestMeasuredFrameIndex = 0;
1216
1097
  _indicesToKeys: Map<number, string> = new Map();
1217
- _nestedChildLists: Map<
1218
- string,
1219
- {
1220
- ref: ?VirtualizedList,
1221
- state: ?ChildListState,
1222
- ...
1223
- },
1224
- > = new Map();
1098
+ _lastFocusedCellKey: ?string = null;
1099
+ _nestedChildLists: ChildListCollection<VirtualizedList> =
1100
+ new ChildListCollection();
1225
1101
  _offsetFromParentVirtualizedList: number = 0;
1226
1102
  _prevParentOffset: number = 0;
1103
+ // $FlowFixMe[missing-local-annot]
1227
1104
  _scrollMetrics = {
1228
1105
  contentLength: 0,
1229
1106
  dOffset: 0,
@@ -1250,7 +1127,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1250
1127
  _computeBlankness() {
1251
1128
  this._fillRateHelper.computeBlankness(
1252
1129
  this.props,
1253
- this.state,
1130
+ this.state.cellsAroundViewport,
1254
1131
  this._scrollMetrics,
1255
1132
  );
1256
1133
  }
@@ -1271,6 +1148,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1271
1148
  );
1272
1149
  return (
1273
1150
  // $FlowFixMe[prop-missing] Invalid prop usage
1151
+ // $FlowFixMe[incompatible-use]
1274
1152
  <ScrollView
1275
1153
  {...props}
1276
1154
  refreshControl={
@@ -1289,6 +1167,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1289
1167
  );
1290
1168
  } else {
1291
1169
  // $FlowFixMe[prop-missing] Invalid prop usage
1170
+ // $FlowFixMe[incompatible-use]
1292
1171
  return <ScrollView {...props} />;
1293
1172
  }
1294
1173
  };
@@ -1325,9 +1204,25 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1325
1204
  this._triggerRemeasureForChildListsInCell(cellKey);
1326
1205
 
1327
1206
  this._computeBlankness();
1328
- this._updateViewableItems(this.props.data);
1207
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1329
1208
  };
1330
1209
 
1210
+ _onCellFocusCapture(cellKey: string) {
1211
+ this._lastFocusedCellKey = cellKey;
1212
+ const renderMask = VirtualizedList._createRenderMask(
1213
+ this.props,
1214
+ this.state.cellsAroundViewport,
1215
+ this._getNonViewportRenderRegions(this.props),
1216
+ );
1217
+
1218
+ this.setState(state => {
1219
+ if (!renderMask.equals(state.renderMask)) {
1220
+ return {renderMask};
1221
+ }
1222
+ return null;
1223
+ });
1224
+ }
1225
+
1331
1226
  _onCellUnmount = (cellKey: string) => {
1332
1227
  const curr = this._frames[cellKey];
1333
1228
  if (curr) {
@@ -1336,15 +1231,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1336
1231
  };
1337
1232
 
1338
1233
  _triggerRemeasureForChildListsInCell(cellKey: string): void {
1339
- const childListKeys = this._cellKeysToChildListKeys.get(cellKey);
1340
- if (childListKeys) {
1341
- for (let childKey of childListKeys) {
1342
- const childList = this._nestedChildLists.get(childKey);
1343
- childList &&
1344
- childList.ref &&
1345
- childList.ref.measureLayoutRelativeToContainingList();
1346
- }
1347
- }
1234
+ this._nestedChildLists.forEachInCell(cellKey, childList => {
1235
+ childList.measureLayoutRelativeToContainingList();
1236
+ });
1348
1237
  }
1349
1238
 
1350
1239
  measureLayoutRelativeToContainingList(): void {
@@ -1378,15 +1267,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1378
1267
 
1379
1268
  // If metrics of the scrollView changed, then we triggered remeasure for child list
1380
1269
  // to ensure VirtualizedList has the right information.
1381
- this._cellKeysToChildListKeys.forEach(childListKeys => {
1382
- if (childListKeys) {
1383
- for (let childKey of childListKeys) {
1384
- const childList = this._nestedChildLists.get(childKey);
1385
- childList &&
1386
- childList.ref &&
1387
- childList.ref.measureLayoutRelativeToContainingList();
1388
- }
1389
- }
1270
+ this._nestedChildLists.forEach(childList => {
1271
+ childList.measureLayoutRelativeToContainingList();
1390
1272
  });
1391
1273
  }
1392
1274
  },
@@ -1437,6 +1319,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1437
1319
  this._headerLength = this._selectLength(e.nativeEvent.layout);
1438
1320
  };
1439
1321
 
1322
+ // $FlowFixMe[missing-local-annot]
1440
1323
  _renderDebugOverlay() {
1441
1324
  const normalize =
1442
1325
  this._scrollMetrics.visibleLength /
@@ -1444,7 +1327,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1444
1327
  const framesInLayout = [];
1445
1328
  const itemCount = this.props.getItemCount(this.props.data);
1446
1329
  for (let ii = 0; ii < itemCount; ii++) {
1447
- const frame = this.__getFrameMetricsApprox(ii);
1330
+ const frame = this.__getFrameMetricsApprox(ii, this.props);
1448
1331
  /* $FlowFixMe[prop-missing] (>=0.68.0 site=react_native_fb) This comment
1449
1332
  * suppresses an error found when Flow v0.68 was deployed. To see the
1450
1333
  * error delete this comment and run Flow. */
@@ -1452,8 +1335,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1452
1335
  framesInLayout.push(frame);
1453
1336
  }
1454
1337
  }
1455
- const windowTop = this.__getFrameMetricsApprox(this.state.first).offset;
1456
- const frameLast = this.__getFrameMetricsApprox(this.state.last);
1338
+ const windowTop = this.__getFrameMetricsApprox(
1339
+ this.state.cellsAroundViewport.first,
1340
+ this.props,
1341
+ ).offset;
1342
+ const frameLast = this.__getFrameMetricsApprox(
1343
+ this.state.cellsAroundViewport.last,
1344
+ this.props,
1345
+ );
1457
1346
  const windowLen = frameLast.offset + frameLast.length - windowTop;
1458
1347
  const visTop = this._scrollMetrics.offset;
1459
1348
  const visLen = this._scrollMetrics.visibleLength;
@@ -1537,7 +1426,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1537
1426
  onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : 2;
1538
1427
  if (
1539
1428
  onEndReached &&
1540
- this.state.last === getItemCount(data) - 1 &&
1429
+ this.state.cellsAroundViewport.last === getItemCount(data) - 1 &&
1541
1430
  distanceFromEnd <= threshold &&
1542
1431
  this._scrollMetrics.contentLength !== this._sentEndForContentLength
1543
1432
  ) {
@@ -1582,7 +1471,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1582
1471
  visibleLength: number,
1583
1472
  offset: number,
1584
1473
  ...
1585
- }) => {
1474
+ }): $FlowFixMe => {
1586
1475
  // Offset of the top of the nested list relative to the top of its parent's viewport
1587
1476
  const offset = metrics.offset - this._offsetFromParentVirtualizedList;
1588
1477
  // Child's visible length is the same as its parent's
@@ -1600,7 +1489,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1600
1489
 
1601
1490
  _onScroll = (e: Object) => {
1602
1491
  this._nestedChildLists.forEach(childList => {
1603
- childList.ref && childList.ref._onScroll(e);
1492
+ childList._onScroll(e);
1604
1493
  });
1605
1494
  if (this.props.onScroll) {
1606
1495
  this.props.onScroll(e);
@@ -1656,7 +1545,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1656
1545
  visibleLength,
1657
1546
  zoomScale,
1658
1547
  };
1659
- this._updateViewableItems(this.props.data);
1548
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1660
1549
  if (!this.props) {
1661
1550
  return;
1662
1551
  }
@@ -1669,7 +1558,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1669
1558
  };
1670
1559
 
1671
1560
  _scheduleCellsToRenderUpdate() {
1672
- const {first, last} = this.state;
1561
+ const {first, last} = this.state.cellsAroundViewport;
1673
1562
  const {offset, visibleLength, velocity} = this._scrollMetrics;
1674
1563
  const itemCount = this.props.getItemCount(this.props.data);
1675
1564
  let hiPri = false;
@@ -1680,15 +1569,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1680
1569
  // Mark as high priority if we're close to the start of the first item
1681
1570
  // But only if there are items before the first rendered item
1682
1571
  if (first > 0) {
1683
- const distTop = offset - this.__getFrameMetricsApprox(first).offset;
1572
+ const distTop =
1573
+ offset - this.__getFrameMetricsApprox(first, this.props).offset;
1684
1574
  hiPri =
1685
1575
  hiPri || distTop < 0 || (velocity < -2 && distTop < scrollingThreshold);
1686
1576
  }
1687
1577
  // Mark as high priority if we're close to the end of the last item
1688
1578
  // But only if there are items after the last rendered item
1689
- if (last < itemCount - 1) {
1579
+ if (last >= 0 && last < itemCount - 1) {
1690
1580
  const distBottom =
1691
- this.__getFrameMetricsApprox(last).offset - (offset + visibleLength);
1581
+ this.__getFrameMetricsApprox(last, this.props).offset -
1582
+ (offset + visibleLength);
1692
1583
  hiPri =
1693
1584
  hiPri ||
1694
1585
  distBottom < 0 ||
@@ -1719,7 +1610,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1719
1610
 
1720
1611
  _onScrollBeginDrag = (e: ScrollEvent): void => {
1721
1612
  this._nestedChildLists.forEach(childList => {
1722
- childList.ref && childList.ref._onScrollBeginDrag(e);
1613
+ childList._onScrollBeginDrag(e);
1723
1614
  });
1724
1615
  this._viewabilityTuples.forEach(tuple => {
1725
1616
  tuple.viewabilityHelper.recordInteraction();
@@ -1730,7 +1621,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1730
1621
 
1731
1622
  _onScrollEndDrag = (e: ScrollEvent): void => {
1732
1623
  this._nestedChildLists.forEach(childList => {
1733
- childList.ref && childList.ref._onScrollEndDrag(e);
1624
+ childList._onScrollEndDrag(e);
1734
1625
  });
1735
1626
  const {velocity} = e.nativeEvent;
1736
1627
  if (velocity) {
@@ -1742,14 +1633,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1742
1633
 
1743
1634
  _onMomentumScrollBegin = (e: ScrollEvent): void => {
1744
1635
  this._nestedChildLists.forEach(childList => {
1745
- childList.ref && childList.ref._onMomentumScrollBegin(e);
1636
+ childList._onMomentumScrollBegin(e);
1746
1637
  });
1747
1638
  this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
1748
1639
  };
1749
1640
 
1750
1641
  _onMomentumScrollEnd = (e: ScrollEvent): void => {
1751
1642
  this._nestedChildLists.forEach(childList => {
1752
- childList.ref && childList.ref._onMomentumScrollEnd(e);
1643
+ childList._onMomentumScrollEnd(e);
1753
1644
  });
1754
1645
  this._scrollMetrics.velocity = 0;
1755
1646
  this._computeBlankness();
@@ -1757,126 +1648,80 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1757
1648
  };
1758
1649
 
1759
1650
  _updateCellsToRender = () => {
1760
- const {
1761
- data,
1762
- getItemCount,
1763
- onEndReachedThreshold: _onEndReachedThreshold,
1764
- } = this.props;
1765
- const onEndReachedThreshold = onEndReachedThresholdOrDefault(
1766
- _onEndReachedThreshold,
1767
- );
1768
- const isVirtualizationDisabled = this._isVirtualizationDisabled();
1769
- this._updateViewableItems(data);
1770
- if (!data) {
1771
- return;
1772
- }
1773
- this.setState(state => {
1774
- let newState: ?(
1775
- | {first: number, last: number, ...}
1776
- | $TEMPORARY$object<{first: number, last: number}>
1651
+ this.setState((state, props) => {
1652
+ const cellsAroundViewport = this._adjustCellsAroundViewport(
1653
+ props,
1654
+ state.cellsAroundViewport,
1777
1655
  );
1778
- const {contentLength, offset, visibleLength} = this._scrollMetrics;
1779
- const distanceFromEnd = contentLength - visibleLength - offset;
1780
- if (!isVirtualizationDisabled) {
1781
- // If we run this with bogus data, we'll force-render window {first: 0, last: 0},
1782
- // and wipe out the initialNumToRender rendered elements.
1783
- // So let's wait until the scroll view metrics have been set up. And until then,
1784
- // we will trust the initialNumToRender suggestion
1785
- if (visibleLength > 0 && contentLength > 0) {
1786
- // If we have a non-zero initialScrollIndex and run this before we've scrolled,
1787
- // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
1788
- // So let's wait until we've scrolled the view to the right place. And until then,
1789
- // we will trust the initialScrollIndex suggestion.
1790
-
1791
- // Thus, we want to recalculate the windowed render limits if any of the following hold:
1792
- // - initialScrollIndex is undefined or is 0
1793
- // - initialScrollIndex > 0 AND scrolling is complete
1794
- // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
1795
- // where the list is shorter than the visible area)
1796
- if (
1797
- !this.props.initialScrollIndex ||
1798
- this._scrollMetrics.offset ||
1799
- Math.abs(distanceFromEnd) < Number.EPSILON
1800
- ) {
1801
- newState = computeWindowedRenderLimits(
1802
- this.props.data,
1803
- this.props.getItemCount,
1804
- maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch),
1805
- windowSizeOrDefault(this.props.windowSize),
1806
- state,
1807
- this.__getFrameMetricsApprox,
1808
- this._scrollMetrics,
1809
- );
1810
- }
1811
- }
1812
- } else {
1813
- const renderAhead =
1814
- distanceFromEnd < onEndReachedThreshold * visibleLength
1815
- ? maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
1816
- : 0;
1817
- newState = {
1818
- first: 0,
1819
- last: Math.min(state.last + renderAhead, getItemCount(data) - 1),
1820
- };
1821
- }
1822
- if (newState && this._nestedChildLists.size > 0) {
1823
- const newFirst = newState.first;
1824
- const newLast = newState.last;
1825
- // If some cell in the new state has a child list in it, we should only render
1826
- // up through that item, so that we give that list a chance to render.
1827
- // Otherwise there's churn from multiple child lists mounting and un-mounting
1828
- // their items.
1829
- for (let ii = newFirst; ii <= newLast; ii++) {
1830
- const cellKeyForIndex = this._indicesToKeys.get(ii);
1831
- const childListKeys =
1832
- cellKeyForIndex &&
1833
- this._cellKeysToChildListKeys.get(cellKeyForIndex);
1834
- if (!childListKeys) {
1835
- continue;
1836
- }
1837
- let someChildHasMore = false;
1838
- // For each cell, need to check whether any child list in it has more elements to render
1839
- for (let childKey of childListKeys) {
1840
- const childList = this._nestedChildLists.get(childKey);
1841
- if (childList && childList.ref && childList.ref.hasMore()) {
1842
- someChildHasMore = true;
1843
- break;
1844
- }
1845
- }
1846
- if (someChildHasMore) {
1847
- newState.last = ii;
1848
- break;
1849
- }
1850
- }
1851
- }
1656
+ const renderMask = VirtualizedList._createRenderMask(
1657
+ props,
1658
+ cellsAroundViewport,
1659
+ this._getNonViewportRenderRegions(props),
1660
+ );
1661
+
1852
1662
  if (
1853
- newState != null &&
1854
- newState.first === state.first &&
1855
- newState.last === state.last
1663
+ cellsAroundViewport.first === state.cellsAroundViewport.first &&
1664
+ cellsAroundViewport.last === state.cellsAroundViewport.last &&
1665
+ renderMask.equals(state.renderMask)
1856
1666
  ) {
1857
- newState = null;
1667
+ return null;
1858
1668
  }
1859
- return newState;
1669
+
1670
+ return {cellsAroundViewport, renderMask};
1860
1671
  });
1861
1672
  };
1862
1673
 
1863
- _createViewToken = (index: number, isViewable: boolean) => {
1864
- const {data, getItem} = this.props;
1674
+ _createViewToken = (
1675
+ index: number,
1676
+ isViewable: boolean,
1677
+ props: FrameMetricProps,
1678
+ // $FlowFixMe[missing-local-annot]
1679
+ ) => {
1680
+ const {data, getItem} = props;
1865
1681
  const item = getItem(data, index);
1866
- return {index, item, key: this._keyExtractor(item, index), isViewable};
1682
+ return {
1683
+ index,
1684
+ item,
1685
+ key: this._keyExtractor(item, index, props),
1686
+ isViewable,
1687
+ };
1867
1688
  };
1868
1689
 
1869
- __getFrameMetricsApprox: (index: number) => {
1690
+ /**
1691
+ * Gets an approximate offset to an item at a given index. Supports
1692
+ * fractional indices.
1693
+ */
1694
+ _getOffsetApprox = (index: number, props: FrameMetricProps): number => {
1695
+ if (Number.isInteger(index)) {
1696
+ return this.__getFrameMetricsApprox(index, props).offset;
1697
+ } else {
1698
+ const frameMetrics = this.__getFrameMetricsApprox(
1699
+ Math.floor(index),
1700
+ props,
1701
+ );
1702
+ const remainder = index - Math.floor(index);
1703
+ return frameMetrics.offset + remainder * frameMetrics.length;
1704
+ }
1705
+ };
1706
+
1707
+ __getFrameMetricsApprox: (
1708
+ index: number,
1709
+ props: FrameMetricProps,
1710
+ ) => {
1870
1711
  length: number,
1871
1712
  offset: number,
1872
1713
  ...
1873
- } = index => {
1874
- const frame = this._getFrameMetrics(index);
1714
+ } = (index, props) => {
1715
+ const frame = this._getFrameMetrics(index, props);
1875
1716
  if (frame && frame.index === index) {
1876
1717
  // check for invalid frames due to row re-ordering
1877
1718
  return frame;
1878
1719
  } else {
1879
- const {getItemLayout} = this.props;
1720
+ const {data, getItemCount, getItemLayout} = props;
1721
+ invariant(
1722
+ index >= 0 && index < getItemCount(data),
1723
+ 'Tried to get frame for out of range index ' + index,
1724
+ );
1880
1725
  invariant(
1881
1726
  !getItemLayout,
1882
1727
  'Should not have to estimate frames when a measurement metrics function is provided',
@@ -1890,6 +1735,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1890
1735
 
1891
1736
  _getFrameMetrics = (
1892
1737
  index: number,
1738
+ props: FrameMetricProps,
1893
1739
  ): ?{
1894
1740
  length: number,
1895
1741
  offset: number,
@@ -1897,13 +1743,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1897
1743
  inLayout?: boolean,
1898
1744
  ...
1899
1745
  } => {
1900
- const {data, getItem, getItemCount, getItemLayout} = this.props;
1746
+ const {data, getItem, getItemCount, getItemLayout} = props;
1901
1747
  invariant(
1902
- getItemCount(data) > index,
1748
+ index >= 0 && index < getItemCount(data),
1903
1749
  'Tried to get frame for out of range index ' + index,
1904
1750
  );
1905
1751
  const item = getItem(data, index);
1906
- const frame = item && this._frames[this._keyExtractor(item, index)];
1752
+ const frame = item && this._frames[this._keyExtractor(item, index, props)];
1907
1753
  if (!frame || frame.index !== index) {
1908
1754
  if (getItemLayout) {
1909
1755
  /* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
@@ -1915,260 +1761,83 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1915
1761
  return frame;
1916
1762
  };
1917
1763
 
1918
- _updateViewableItems(data: any) {
1919
- const {getItemCount} = this.props;
1764
+ _getNonViewportRenderRegions = (
1765
+ props: FrameMetricProps,
1766
+ ): $ReadOnlyArray<{
1767
+ first: number,
1768
+ last: number,
1769
+ }> => {
1770
+ // Keep a viewport's worth of content around the last focused cell to allow
1771
+ // random navigation around it without any blanking. E.g. tabbing from one
1772
+ // focused item out of viewport to another.
1773
+ if (
1774
+ !(this._lastFocusedCellKey && this._cellRefs[this._lastFocusedCellKey])
1775
+ ) {
1776
+ return [];
1777
+ }
1778
+
1779
+ const lastFocusedCellRenderer = this._cellRefs[this._lastFocusedCellKey];
1780
+ const focusedCellIndex = lastFocusedCellRenderer.props.index;
1781
+ const itemCount = props.getItemCount(props.data);
1782
+
1783
+ // The cell may have been unmounted and have a stale index
1784
+ if (
1785
+ focusedCellIndex >= itemCount ||
1786
+ this._indicesToKeys.get(focusedCellIndex) !== this._lastFocusedCellKey
1787
+ ) {
1788
+ return [];
1789
+ }
1920
1790
 
1791
+ let first = focusedCellIndex;
1792
+ let heightOfCellsBeforeFocused = 0;
1793
+ for (
1794
+ let i = first - 1;
1795
+ i >= 0 && heightOfCellsBeforeFocused < this._scrollMetrics.visibleLength;
1796
+ i--
1797
+ ) {
1798
+ first--;
1799
+ heightOfCellsBeforeFocused += this.__getFrameMetricsApprox(
1800
+ i,
1801
+ props,
1802
+ ).length;
1803
+ }
1804
+
1805
+ let last = focusedCellIndex;
1806
+ let heightOfCellsAfterFocused = 0;
1807
+ for (
1808
+ let i = last + 1;
1809
+ i < itemCount &&
1810
+ heightOfCellsAfterFocused < this._scrollMetrics.visibleLength;
1811
+ i++
1812
+ ) {
1813
+ last++;
1814
+ heightOfCellsAfterFocused += this.__getFrameMetricsApprox(
1815
+ i,
1816
+ props,
1817
+ ).length;
1818
+ }
1819
+
1820
+ return [{first, last}];
1821
+ };
1822
+
1823
+ _updateViewableItems(
1824
+ props: FrameMetricProps,
1825
+ cellsAroundViewport: {first: number, last: number},
1826
+ ) {
1921
1827
  this._viewabilityTuples.forEach(tuple => {
1922
1828
  tuple.viewabilityHelper.onUpdate(
1923
- getItemCount(data),
1829
+ props,
1924
1830
  this._scrollMetrics.offset,
1925
1831
  this._scrollMetrics.visibleLength,
1926
1832
  this._getFrameMetrics,
1927
1833
  this._createViewToken,
1928
1834
  tuple.onViewableItemsChanged,
1929
- this.state,
1835
+ cellsAroundViewport,
1930
1836
  );
1931
1837
  });
1932
1838
  }
1933
1839
  }
1934
1840
 
1935
- type CellRendererProps = {
1936
- CellRendererComponent?: ?React.ComponentType<any>,
1937
- ItemSeparatorComponent: ?React.ComponentType<
1938
- any | {highlighted: boolean, leadingItem: ?Item},
1939
- >,
1940
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
1941
- cellKey: string,
1942
- debug?: ?boolean,
1943
- fillRateHelper: FillRateHelper,
1944
- getItemLayout?: (
1945
- data: any,
1946
- index: number,
1947
- ) => {
1948
- length: number,
1949
- offset: number,
1950
- index: number,
1951
- ...
1952
- },
1953
- horizontal: ?boolean,
1954
- index: number,
1955
- inversionStyle: ViewStyleProp,
1956
- item: Item,
1957
- // This is extracted by ScrollViewStickyHeader
1958
- onCellLayout: (event: Object, cellKey: string, index: number) => void,
1959
- onUnmount: (cellKey: string) => void,
1960
- onUpdateSeparators: (cellKeys: Array<?string>, props: Object) => void,
1961
- prevCellKey: ?string,
1962
- renderItem?: ?RenderItemType<Item>,
1963
- ...
1964
- };
1965
-
1966
- type CellRendererState = {
1967
- separatorProps: $ReadOnly<{|
1968
- highlighted: boolean,
1969
- leadingItem: ?Item,
1970
- |}>,
1971
- ...
1972
- };
1973
-
1974
- class CellRenderer extends React.Component<
1975
- CellRendererProps,
1976
- CellRendererState,
1977
- > {
1978
- state = {
1979
- separatorProps: {
1980
- highlighted: false,
1981
- leadingItem: this.props.item,
1982
- },
1983
- };
1984
-
1985
- static getDerivedStateFromProps(
1986
- props: CellRendererProps,
1987
- prevState: CellRendererState,
1988
- ): ?CellRendererState {
1989
- return {
1990
- separatorProps: {
1991
- ...prevState.separatorProps,
1992
- leadingItem: props.item,
1993
- },
1994
- };
1995
- }
1996
-
1997
- // TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
1998
- // reused by SectionList and we can keep VirtualizedList simpler.
1999
- _separators = {
2000
- highlight: () => {
2001
- const {cellKey, prevCellKey} = this.props;
2002
- this.props.onUpdateSeparators([cellKey, prevCellKey], {
2003
- highlighted: true,
2004
- });
2005
- },
2006
- unhighlight: () => {
2007
- const {cellKey, prevCellKey} = this.props;
2008
- this.props.onUpdateSeparators([cellKey, prevCellKey], {
2009
- highlighted: false,
2010
- });
2011
- },
2012
- updateProps: (select: 'leading' | 'trailing', newProps: Object) => {
2013
- const {cellKey, prevCellKey} = this.props;
2014
- this.props.onUpdateSeparators(
2015
- [select === 'leading' ? prevCellKey : cellKey],
2016
- newProps,
2017
- );
2018
- },
2019
- };
2020
-
2021
- updateSeparatorProps(newProps: Object) {
2022
- this.setState(state => ({
2023
- separatorProps: {...state.separatorProps, ...newProps},
2024
- }));
2025
- }
2026
-
2027
- componentWillUnmount() {
2028
- this.props.onUnmount(this.props.cellKey);
2029
- }
2030
-
2031
- _onLayout = (nativeEvent: LayoutEvent): void => {
2032
- this.props.onCellLayout &&
2033
- this.props.onCellLayout(
2034
- nativeEvent,
2035
- this.props.cellKey,
2036
- this.props.index,
2037
- );
2038
- };
2039
-
2040
- _renderElement(
2041
- renderItem: any,
2042
- ListItemComponent: any,
2043
- item: any,
2044
- index: any,
2045
- ) {
2046
- if (renderItem && ListItemComponent) {
2047
- console.warn(
2048
- 'VirtualizedList: Both ListItemComponent and renderItem props are present. ListItemComponent will take' +
2049
- ' precedence over renderItem.',
2050
- );
2051
- }
2052
-
2053
- if (ListItemComponent) {
2054
- /* $FlowFixMe[not-a-component] (>=0.108.0 site=react_native_fb) This
2055
- * comment suppresses an error found when Flow v0.108 was deployed. To
2056
- * see the error, delete this comment and run Flow. */
2057
- /* $FlowFixMe[incompatible-type-arg] (>=0.108.0 site=react_native_fb)
2058
- * This comment suppresses an error found when Flow v0.108 was deployed.
2059
- * To see the error, delete this comment and run Flow. */
2060
- return React.createElement(ListItemComponent, {
2061
- item,
2062
- index,
2063
- separators: this._separators,
2064
- });
2065
- }
2066
-
2067
- if (renderItem) {
2068
- return renderItem({
2069
- item,
2070
- index,
2071
- separators: this._separators,
2072
- });
2073
- }
2074
-
2075
- invariant(
2076
- false,
2077
- 'VirtualizedList: Either ListItemComponent or renderItem props are required but none were found.',
2078
- );
2079
- }
2080
-
2081
- render() {
2082
- const {
2083
- CellRendererComponent,
2084
- ItemSeparatorComponent,
2085
- ListItemComponent,
2086
- debug,
2087
- fillRateHelper,
2088
- getItemLayout,
2089
- horizontal,
2090
- item,
2091
- index,
2092
- inversionStyle,
2093
- renderItem,
2094
- } = this.props;
2095
- const element = this._renderElement(
2096
- renderItem,
2097
- ListItemComponent,
2098
- item,
2099
- index,
2100
- );
2101
-
2102
- const onLayout =
2103
- (getItemLayout && !debug && !fillRateHelper.enabled()) ||
2104
- !this.props.onCellLayout
2105
- ? undefined
2106
- : this._onLayout;
2107
- // NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
2108
- // called explicitly by `ScrollViewStickyHeader`.
2109
- const itemSeparator = React.isValidElement(ItemSeparatorComponent)
2110
- ? ItemSeparatorComponent
2111
- : ItemSeparatorComponent && (
2112
- <ItemSeparatorComponent {...this.state.separatorProps} />
2113
- );
2114
- const cellStyle = inversionStyle
2115
- ? horizontal
2116
- ? [styles.rowReverse, inversionStyle]
2117
- : [styles.columnReverse, inversionStyle]
2118
- : horizontal
2119
- ? [styles.row, inversionStyle]
2120
- : inversionStyle;
2121
- const result = !CellRendererComponent ? (
2122
- /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) *
2123
- This comment suppresses an error found when Flow v0.89 was deployed. *
2124
- To see the error, delete this comment and run Flow. */
2125
- <View style={cellStyle} onLayout={onLayout}>
2126
- {element}
2127
- {itemSeparator}
2128
- </View>
2129
- ) : (
2130
- <CellRendererComponent
2131
- {...this.props}
2132
- style={cellStyle}
2133
- onLayout={onLayout}>
2134
- {element}
2135
- {itemSeparator}
2136
- </CellRendererComponent>
2137
- );
2138
-
2139
- return (
2140
- <VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
2141
- {result}
2142
- </VirtualizedListCellContextProvider>
2143
- );
2144
- }
2145
- }
2146
-
2147
- function describeNestedLists(childList: {
2148
- +cellKey: string,
2149
- +key: string,
2150
- +ref: VirtualizedList,
2151
- +parentDebugInfo: ListDebugInfo,
2152
- +horizontal: boolean,
2153
- ...
2154
- }) {
2155
- let trace =
2156
- 'VirtualizedList trace:\n' +
2157
- ` Child (${childList.horizontal ? 'horizontal' : 'vertical'}):\n` +
2158
- ` listKey: ${childList.key}\n` +
2159
- ` cellKey: ${childList.cellKey}`;
2160
-
2161
- let debugInfo: ?ListDebugInfo = childList.parentDebugInfo;
2162
- while (debugInfo) {
2163
- trace +=
2164
- `\n Parent (${debugInfo.horizontal ? 'horizontal' : 'vertical'}):\n` +
2165
- ` listKey: ${debugInfo.listKey}\n` +
2166
- ` cellKey: ${debugInfo.cellKey}`;
2167
- debugInfo = debugInfo.parent;
2168
- }
2169
- return trace;
2170
- }
2171
-
2172
1841
  const styles = StyleSheet.create({
2173
1842
  verticallyInverted: {
2174
1843
  transform: [{scaleY: -1}],
@@ -2176,15 +1845,6 @@ const styles = StyleSheet.create({
2176
1845
  horizontallyInverted: {
2177
1846
  transform: [{scaleX: -1}],
2178
1847
  },
2179
- row: {
2180
- flexDirection: 'row',
2181
- },
2182
- rowReverse: {
2183
- flexDirection: 'row-reverse',
2184
- },
2185
- columnReverse: {
2186
- flexDirection: 'column-reverse',
2187
- },
2188
1848
  debug: {
2189
1849
  flex: 1,
2190
1850
  },
@@ -2214,5 +1874,3 @@ const styles = StyleSheet.create({
2214
1874
  borderWidth: 2,
2215
1875
  },
2216
1876
  });
2217
-
2218
- module.exports = VirtualizedList;