@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.
- package/.eslintignore +1 -0
- package/.eslintrc.js +2 -0
- package/.flowconfig +3 -6
- package/CHANGELOG.json +281 -43
- package/CHANGELOG.md +105 -24
- package/IntegrationTests/AccessibilityManagerTest.js +1 -1
- package/IntegrationTests/AppEventsTest.js +0 -1
- package/IntegrationTests/BUCK +0 -1
- package/IntegrationTests/GlobalEvalWithSourceUrlTest.js +1 -1
- package/IntegrationTests/ImageSnapshotTest.js +1 -1
- package/IntegrationTests/IntegrationTestsApp.js +2 -3
- package/IntegrationTests/SimpleSnapshotTest.js +1 -1
- package/IntegrationTests/SyncMethodTest.js +1 -1
- package/IntegrationTests/TimersTest.js +4 -4
- package/IntegrationTests/WebSocketTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +80 -0
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +4 -3
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
- package/Libraries/Alert/Alert.d.ts +90 -0
- package/Libraries/Alert/Alert.js +7 -1
- package/Libraries/Alert/Alert.win32.js +1 -0
- package/Libraries/Alert/NativeAlertManager.js +2 -0
- package/Libraries/Alert/RCTAlertManager.ios.js +2 -1
- package/Libraries/Animated/Animated.d.ts +587 -0
- package/Libraries/Animated/Animated.js +13 -11
- package/Libraries/Animated/AnimatedEvent.js +12 -17
- package/Libraries/Animated/AnimatedImplementation.js +21 -23
- package/Libraries/Animated/AnimatedMock.js +11 -13
- package/Libraries/Animated/AnimatedWeb.js +2 -2
- package/Libraries/Animated/Easing.d.ts +37 -0
- package/Libraries/Animated/Easing.js +2 -2
- package/Libraries/Animated/NativeAnimatedHelper.js +32 -22
- package/Libraries/Animated/NativeAnimatedModule.js +1 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
- package/Libraries/Animated/SpringConfig.js +2 -7
- package/Libraries/Animated/animations/Animation.js +3 -4
- package/Libraries/Animated/animations/DecayAnimation.js +5 -8
- package/Libraries/Animated/animations/SpringAnimation.js +9 -14
- package/Libraries/Animated/animations/TimingAnimation.js +9 -13
- package/Libraries/Animated/bezier.js +2 -2
- package/Libraries/Animated/components/AnimatedFlatList.js +5 -6
- package/Libraries/Animated/components/AnimatedImage.js +5 -6
- package/Libraries/Animated/components/AnimatedScrollView.js +110 -14
- package/Libraries/Animated/components/AnimatedSectionList.js +4 -5
- package/Libraries/Animated/components/AnimatedText.js +5 -6
- package/Libraries/Animated/components/AnimatedView.js +5 -6
- package/Libraries/Animated/createAnimatedComponent.js +13 -20
- package/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +2 -2
- package/Libraries/Animated/nodes/AnimatedAddition.js +6 -8
- package/Libraries/Animated/nodes/AnimatedColor.js +7 -7
- package/Libraries/Animated/nodes/AnimatedDiffClamp.js +6 -8
- package/Libraries/Animated/nodes/AnimatedDivision.js +7 -9
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +7 -10
- package/Libraries/Animated/nodes/AnimatedModulo.js +6 -8
- package/Libraries/Animated/nodes/AnimatedMultiplication.js +7 -9
- package/Libraries/Animated/nodes/AnimatedNode.js +10 -8
- package/Libraries/Animated/nodes/AnimatedProps.js +12 -30
- package/Libraries/Animated/nodes/AnimatedStyle.js +12 -22
- package/Libraries/Animated/nodes/AnimatedSubtraction.js +7 -9
- package/Libraries/Animated/nodes/AnimatedTracking.js +8 -12
- package/Libraries/Animated/nodes/AnimatedTransform.js +38 -31
- package/Libraries/Animated/nodes/AnimatedValue.js +9 -10
- package/Libraries/Animated/nodes/AnimatedValueXY.js +4 -7
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +4 -5
- package/Libraries/Animated/useAnimatedProps.js +8 -16
- package/Libraries/Animated/useAnimatedValue.d.ts +15 -0
- package/Libraries/Animated/useAnimatedValue.js +25 -0
- package/Libraries/AppState/AppState.d.ts +58 -0
- package/Libraries/AppState/AppState.js +3 -7
- package/Libraries/AppState/NativeAppState.js +1 -0
- package/Libraries/BatchedBridge/MessageQueue.js +9 -5
- package/Libraries/BatchedBridge/NativeModules.d.ts +25 -0
- package/Libraries/BatchedBridge/NativeModules.js +1 -0
- package/Libraries/Blob/BlobManager.js +5 -3
- package/Libraries/Blob/File.js +2 -3
- package/Libraries/Blob/FileReader.js +6 -5
- package/Libraries/Blob/NativeBlobModule.js +1 -0
- package/Libraries/Blob/NativeFileReaderModule.js +1 -0
- package/Libraries/Blob/URL.js +11 -9
- package/Libraries/BugReporting/NativeBugReporting.js +1 -0
- package/Libraries/BugReporting/getReactData.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +128 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.flow.js +208 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +40 -8
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +40 -8
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +1 -0
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +5 -0
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +86 -0
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.flow.js +58 -0
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +7 -8
- package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +2 -3
- package/Libraries/Components/Button.d.ts +42 -0
- package/Libraries/Components/Button.flow.js +265 -0
- package/Libraries/Components/Button.js +62 -18
- package/Libraries/Components/Clipboard/Clipboard.d.ts +28 -0
- package/Libraries/Components/Clipboard/NativeClipboard.js +1 -0
- package/Libraries/Components/DatePicker/DatePickerIOS.android.js +4 -2
- package/Libraries/Components/DatePicker/DatePickerIOS.d.ts +92 -0
- package/Libraries/Components/{MaskedView/MaskedViewIOS.android.js → DatePicker/DatePickerIOS.flow.android.js} +3 -2
- package/Libraries/Components/DatePicker/DatePickerIOS.flow.ios.js +113 -0
- package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +8 -7
- package/Libraries/Components/DatePicker/DatePickerIOS.win32.js +4 -2
- package/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +7 -6
- package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +1 -0
- package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +9 -8
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +13 -14
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +141 -0
- package/Libraries/Components/Keyboard/Keyboard.d.ts +109 -0
- package/Libraries/Components/Keyboard/Keyboard.js +35 -8
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.d.ts +46 -0
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +35 -15
- package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +1 -0
- package/Libraries/Components/Pressable/Pressable.d.ts +167 -0
- package/Libraries/Components/Pressable/Pressable.js +73 -15
- package/Libraries/Components/Pressable/Pressable.win32.js +77 -19
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +6 -3
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +3 -3
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +83 -0
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +2 -2
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +1 -1
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts +62 -0
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +4 -4
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.win32.js +1 -1
- package/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +2 -2
- package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +5 -6
- package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +4 -4
- package/Libraries/Components/RefreshControl/RefreshControl.d.ts +87 -0
- package/Libraries/Components/RefreshControl/RefreshControl.js +4 -3
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -3
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -1
- package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +24 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.flow.js +19 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +5 -4
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +5 -4
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +2 -1
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -1
- package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -1
- package/Libraries/Components/ScrollView/ScrollView.d.ts +911 -0
- package/Libraries/Components/ScrollView/ScrollView.js +87 -52
- package/Libraries/Components/ScrollView/ScrollViewCommands.js +3 -3
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -1
- package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +3 -3
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +243 -269
- package/Libraries/Components/Slider/Slider.d.ts +132 -0
- package/Libraries/Components/Slider/Slider.js +9 -9
- package/Libraries/Components/Slider/SliderNativeComponent.js +4 -5
- package/Libraries/Components/Sound/NativeSoundManager.js +1 -0
- package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +1 -0
- package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +1 -0
- package/Libraries/Components/StatusBar/StatusBar.d.ts +138 -0
- package/Libraries/Components/StatusBar/StatusBar.js +7 -7
- package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +10 -10
- package/Libraries/Components/Switch/Switch.d.ts +115 -0
- package/Libraries/Components/Switch/Switch.js +7 -7
- package/Libraries/Components/Switch/SwitchNativeComponent.js +9 -4
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +40 -12
- package/Libraries/Components/TextInput/InputAccessoryView.d.ts +34 -0
- package/Libraries/Components/TextInput/InputAccessoryView.js +3 -4
- package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +1 -1
- package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +3 -2
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +3 -2
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +3 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +840 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +1057 -0
- package/Libraries/Components/TextInput/TextInput.js +344 -38
- package/Libraries/Components/TextInput/TextInput.win32.d.ts +1 -1
- package/Libraries/Components/TextInput/TextInput.win32.js +1 -1
- package/Libraries/Components/TextInput/TextInput.win32.js.map +1 -1
- package/Libraries/Components/TextInput/TextInputNativeCommands.js +2 -2
- package/Libraries/Components/TextInput/TextInputState.js +22 -5
- package/Libraries/Components/TextInput/TextInputState.win32.js +24 -5
- package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +1 -0
- package/Libraries/Components/ToastAndroid/ToastAndroid.d.ts +47 -0
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/Touchable.d.ts +90 -0
- package/Libraries/Components/Touchable/Touchable.flow.js +258 -0
- package/Libraries/Components/Touchable/Touchable.js +12 -12
- package/Libraries/Components/Touchable/Touchable.win32.js +12 -12
- package/Libraries/Components/Touchable/TouchableBounce.js +44 -10
- package/Libraries/Components/Touchable/TouchableHighlight.d.ts +68 -0
- package/Libraries/Components/Touchable/TouchableHighlight.js +32 -9
- package/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts +114 -0
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +54 -20
- package/Libraries/Components/Touchable/TouchableOpacity.d.ts +109 -0
- package/Libraries/Components/Touchable/TouchableOpacity.js +54 -16
- package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +2 -1
- package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js +0 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +143 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +64 -10
- package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +1 -1
- package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +13 -2
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
- package/Libraries/Components/View/View.d.ts +29 -0
- package/Libraries/Components/View/View.js +91 -8
- package/Libraries/Components/View/View.win32.js +176 -89
- package/Libraries/Components/View/ViewAccessibility.d.ts +360 -0
- package/Libraries/Components/View/ViewAccessibility.js +70 -1
- package/Libraries/Components/View/ViewNativeComponent.js +3 -3
- package/Libraries/Components/View/ViewPropTypes.d.ts +245 -0
- package/Libraries/Components/View/ViewPropTypes.js +105 -13
- package/Libraries/Components/View/ViewPropTypes.win32.js +105 -13
- package/Libraries/Components/View/ViewWin32.Props.d.ts +6 -1
- package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
- package/Libraries/Core/Devtools/openFileInEditor.js +3 -0
- package/Libraries/Core/Devtools/parseErrorStack.js +1 -1
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
- package/Libraries/Core/ExceptionsManager.js +8 -0
- package/Libraries/Core/ExtendedError.js +11 -8
- package/Libraries/Core/InitializeCore.js +2 -1
- package/Libraries/Core/NativeExceptionsManager.js +3 -4
- package/Libraries/Core/RawEventEmitter.js +2 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +2 -2
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/ReactNativeVersionCheck.js +1 -0
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -0
- package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +1 -0
- package/Libraries/Core/Timers/JSTimers.js +13 -11
- package/Libraries/Core/Timers/NativeTiming.js +1 -0
- package/Libraries/Core/setUpBatchedBridge.js +1 -5
- package/Libraries/Core/setUpDeveloperTools.js +4 -6
- package/Libraries/Core/setUpReactDevTools.js +4 -1
- package/Libraries/Core/setUpRegeneratorRuntime.js +1 -1
- package/Libraries/Core/setUpTimers.js +1 -1
- package/Libraries/EventEmitter/NativeEventEmitter.d.ts +70 -0
- package/Libraries/EventEmitter/NativeEventEmitter.js +1 -0
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +30 -0
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
- package/Libraries/EventEmitter/RCTNativeAppEventEmitter.d.ts +32 -0
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +1 -0
- package/Libraries/Events/EventPolyfill.js +1 -1
- package/Libraries/HeapCapture/NativeJSCHeapCapture.js +1 -0
- package/Libraries/Image/AssetSourceResolver.js +4 -6
- package/Libraries/Image/Image.android.js +63 -45
- package/Libraries/Image/Image.d.ts +322 -0
- package/Libraries/Image/Image.flow.js +64 -0
- package/Libraries/Image/Image.ios.js +55 -28
- package/Libraries/Image/Image.win32.js +54 -25
- package/Libraries/Image/ImageBackground.js +18 -7
- package/Libraries/Image/ImageInjection.js +2 -1
- package/Libraries/Image/ImageProps.js +88 -5
- package/Libraries/Image/ImageResizeMode.d.ts +49 -0
- package/Libraries/Image/ImageSource.d.ts +76 -0
- package/Libraries/Image/ImageSourceUtils.js +80 -0
- package/Libraries/Image/ImageUtils.js +21 -0
- package/Libraries/Image/ImageViewNativeComponent.js +8 -5
- package/Libraries/Image/NativeImageEditor.js +1 -0
- package/Libraries/Image/NativeImageLoaderAndroid.js +1 -0
- package/Libraries/Image/NativeImageLoaderIOS.js +1 -0
- package/Libraries/Image/NativeImageLoaderWin32.js +1 -0
- package/Libraries/Image/NativeImageStoreAndroid.js +1 -0
- package/Libraries/Image/NativeImageStoreIOS.js +1 -0
- package/Libraries/Image/TextInlineImageNativeComponent.js +4 -3
- package/Libraries/Image/nativeImageSource.js +2 -2
- package/Libraries/Image/resolveAssetSource.js +5 -5
- package/Libraries/Inspector/BorderBox.js +1 -1
- package/Libraries/Inspector/BoxInspector.js +3 -4
- package/Libraries/Inspector/DevtoolsOverlay.js +213 -0
- package/Libraries/Inspector/ElementBox.js +4 -5
- package/Libraries/Inspector/ElementProperties.js +10 -11
- package/Libraries/Inspector/Inspector.js +22 -108
- package/Libraries/Inspector/Inspector.win32.js +23 -109
- package/Libraries/Inspector/InspectorOverlay.js +5 -5
- package/Libraries/Inspector/InspectorOverlay.win32.js +5 -5
- package/Libraries/Inspector/InspectorPanel.js +12 -10
- package/Libraries/Inspector/NetworkOverlay.js +7 -3
- package/Libraries/Inspector/PerformanceOverlay.js +3 -3
- package/Libraries/Inspector/StyleInspector.js +2 -2
- package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +71 -0
- package/Libraries/Interaction/BridgeSpyStallHandler.js +1 -1
- package/Libraries/Interaction/InteractionManager.d.ts +74 -0
- package/Libraries/Interaction/InteractionManager.js +8 -8
- package/Libraries/Interaction/NativeFrameRateLogger.js +1 -0
- package/Libraries/Interaction/PanResponder.d.ts +202 -0
- package/Libraries/Interaction/PanResponder.flow.js +257 -0
- package/Libraries/Interaction/PanResponder.js +4 -3
- package/Libraries/JSInspector/JSInspector.js +0 -3
- package/Libraries/JSInspector/NetworkAgent.js +3 -3
- package/Libraries/LayoutAnimation/LayoutAnimation.d.ts +84 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +4 -3
- package/Libraries/Linking/Linking.d.ts +61 -0
- package/Libraries/Linking/Linking.js +3 -2
- package/Libraries/Linking/NativeIntentAndroid.js +1 -0
- package/Libraries/Linking/NativeLinkingManager.js +1 -0
- package/Libraries/Lists/CellRenderMask.js +13 -3
- package/Libraries/Lists/ChildListCollection.js +72 -0
- package/Libraries/Lists/FillRateHelper.js +28 -17
- package/Libraries/Lists/FlatList.d.ts +292 -0
- package/Libraries/Lists/FlatList.js +70 -70
- package/Libraries/Lists/SectionList.d.ts +300 -0
- package/Libraries/Lists/SectionList.js +5 -5
- package/Libraries/Lists/SectionListModern.js +6 -6
- package/Libraries/Lists/StateSafePureComponent.js +85 -0
- package/Libraries/Lists/ViewabilityHelper.js +33 -12
- package/Libraries/Lists/VirtualizeUtils.js +17 -13
- package/Libraries/Lists/VirtualizedList.d.ts +317 -0
- package/Libraries/Lists/VirtualizedList.js +548 -890
- package/Libraries/Lists/VirtualizedListCellRenderer.js +259 -0
- package/Libraries/Lists/VirtualizedListContext.js +7 -48
- package/Libraries/Lists/VirtualizedListProps.js +279 -0
- package/Libraries/Lists/VirtualizedSectionList.js +6 -3
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +9 -8
- package/Libraries/LogBox/Data/LogBoxLog.js +5 -5
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +4 -4
- package/Libraries/LogBox/Data/parseLogBoxLog.js +5 -3
- package/Libraries/LogBox/LogBox.d.ts +28 -0
- package/Libraries/LogBox/LogBox.js +11 -11
- package/Libraries/LogBox/LogBoxInspectorContainer.js +5 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
- package/Libraries/LogBox/UI/AnsiHighlight.js +5 -3
- package/Libraries/LogBox/UI/LogBoxButton.js +6 -5
- package/Libraries/LogBox/UI/LogBoxInspector.js +6 -6
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +3 -3
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +7 -6
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +6 -5
- package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +6 -5
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +7 -6
- package/Libraries/LogBox/UI/LogBoxInspectorSection.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +3 -3
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +5 -5
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +5 -5
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +5 -5
- package/Libraries/LogBox/UI/LogBoxMessage.js +3 -3
- package/Libraries/LogBox/UI/LogBoxNotification.js +6 -5
- package/Libraries/Modal/Modal.d.ts +104 -0
- package/Libraries/Modal/Modal.js +14 -14
- package/Libraries/Modal/NativeModalManager.js +1 -0
- package/Libraries/Modal/RCTModalHostViewNativeComponent.js +3 -3
- package/Libraries/NativeComponent/BaseViewConfig.android.js +27 -2
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +8 -3
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +8 -3
- package/Libraries/NativeComponent/NativeComponentRegistry.js +5 -4
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +1 -0
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +1 -1
- package/Libraries/NativeComponent/ViewConfig.js +1 -0
- package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +1 -0
- package/Libraries/NativeModules/specs/NativeDevMenu.js +1 -0
- package/Libraries/NativeModules/specs/NativeDevSettings.js +1 -0
- package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +1 -0
- package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +1 -0
- package/Libraries/NativeModules/specs/NativeLogBox.js +3 -2
- package/Libraries/NativeModules/specs/NativeRedBox.js +1 -0
- package/Libraries/NativeModules/specs/NativeSourceCode.js +1 -0
- package/Libraries/Network/NativeNetworkingAndroid.js +1 -0
- package/Libraries/Network/NativeNetworkingIOS.js +1 -0
- package/Libraries/Network/RCTNetworking.android.js +4 -3
- package/Libraries/Network/RCTNetworking.ios.js +3 -2
- package/Libraries/Network/RCTNetworking.win32.js +1 -0
- package/Libraries/Network/convertRequestBody.js +1 -2
- package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -1
- package/Libraries/NewAppScreen/components/Header.js +6 -2
- package/Libraries/NewAppScreen/components/HermesBadge.js +6 -2
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +8 -9
- package/Libraries/NewAppScreen/components/ReloadInstructions.js +4 -1
- package/Libraries/NewAppScreen/index.js +1 -1
- package/Libraries/Performance/NativeJSCSamplingProfiler.js +1 -0
- package/Libraries/Performance/QuickPerformanceLogger.js +34 -10
- package/Libraries/Performance/Systrace.d.ts +66 -0
- package/Libraries/Performance/Systrace.js +110 -195
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +115 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +5 -4
- package/Libraries/Pressability/Pressability.js +12 -10
- package/Libraries/Pressability/Pressability.win32.js +9 -7
- package/Libraries/Pressability/PressabilityDebug.js +2 -2
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
- package/Libraries/PushNotificationIOS/PushNotificationIOS.d.ts +275 -0
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +19 -14
- package/Libraries/ReactNative/AppContainer.js +17 -7
- package/Libraries/ReactNative/AppRegistry.d.ts +68 -0
- package/Libraries/ReactNative/AppRegistry.js +11 -14
- package/Libraries/ReactNative/BridgelessUIManager.js +4 -3
- package/Libraries/ReactNative/FabricUIManager.js +3 -3
- package/Libraries/ReactNative/I18nManager.d.ts +25 -0
- package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +1 -0
- package/Libraries/ReactNative/NativeI18nManager.js +1 -0
- package/Libraries/ReactNative/NativeUIManager.js +1 -0
- package/Libraries/ReactNative/PaperUIManager.js +2 -2
- package/Libraries/ReactNative/PaperUIManager.win32.js +1 -1
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +9 -0
- package/Libraries/ReactNative/RendererImplementation.js +112 -0
- package/Libraries/ReactNative/RendererProxy.d.ts +20 -0
- package/Libraries/ReactNative/RendererProxy.js +26 -0
- package/Libraries/ReactNative/RootTag.js +0 -1
- package/Libraries/ReactNative/UIManager.d.ts +157 -0
- package/Libraries/ReactNative/UIManager.js +1 -1
- package/Libraries/ReactNative/getCachedComponentWithDebugName.js +1 -0
- package/Libraries/ReactNative/renderApplication.js +38 -20
- package/Libraries/ReactNative/requireNativeComponent.d.ts +23 -0
- package/Libraries/ReactNative/requireNativeComponent.js +2 -2
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +10 -9
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +312 -217
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +212 -177
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +248 -213
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +311 -218
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +226 -196
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +262 -232
- package/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +149 -0
- package/Libraries/Renderer/shims/ReactFabric.js +2 -2
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
- package/Libraries/Renderer/shims/ReactNative.js +2 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.d.ts +141 -0
- package/Libraries/Renderer/shims/ReactNativeTypes.js +23 -22
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +8 -8
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
- package/Libraries/Settings/NativeSettingsManager.js +1 -0
- package/Libraries/Settings/Settings.d.ts +18 -0
- package/Libraries/Share/NativeShareModule.js +1 -0
- package/Libraries/Share/Share.d.ts +80 -0
- package/Libraries/Share/Share.js +7 -5
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.d.ts +18 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.d.ts +25 -0
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -0
- package/Libraries/StyleSheet/StyleSheet.d.ts +156 -0
- package/Libraries/StyleSheet/StyleSheet.js +15 -11
- package/Libraries/StyleSheet/StyleSheet.win32.js +16 -12
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +332 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +101 -24
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +2 -2
- package/Libraries/StyleSheet/normalizeColor.js +3 -3
- package/Libraries/StyleSheet/private/_TransformStyle.js +26 -24
- package/Libraries/StyleSheet/processAspectRatio.js +53 -0
- package/Libraries/StyleSheet/processColor.d.ts +16 -0
- package/Libraries/StyleSheet/processColor.js +3 -4
- package/Libraries/StyleSheet/processColorArray.js +1 -0
- package/Libraries/StyleSheet/processFontVariant.js +30 -0
- package/Libraries/StyleSheet/processTransform.js +114 -105
- package/Libraries/StyleSheet/splitLayoutProps.js +5 -0
- package/Libraries/Text/Text.d.ts +209 -0
- package/Libraries/Text/Text.js +94 -12
- package/Libraries/Text/TextNativeComponent.js +49 -41
- package/Libraries/Text/TextNativeComponent.win32.js +67 -48
- package/Libraries/Text/TextProps.js +64 -7
- package/Libraries/{Components/MaskedView/MaskedViewIOS.win32.js → TurboModule/RCTExport.d.ts} +3 -4
- package/Libraries/TurboModule/TurboModuleRegistry.d.ts +15 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +3 -1
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +1 -0
- package/Libraries/Types/CoreEventTypes.d.ts +263 -0
- package/Libraries/Types/CoreEventTypes.js +2 -1
- package/Libraries/Types/CoreEventTypes.win32.js +2 -1
- package/Libraries/Utilities/AcessibilityMapping.js +154 -0
- package/Libraries/Utilities/Appearance.d.ts +43 -0
- package/Libraries/Utilities/Appearance.js +3 -3
- package/Libraries/Utilities/BackHandler.android.js +3 -5
- package/Libraries/Utilities/BackHandler.d.ts +38 -0
- package/Libraries/Utilities/BackHandler.win32.js +3 -5
- package/Libraries/Utilities/DevSettings.d.ts +32 -0
- package/Libraries/Utilities/DevSettings.js +4 -2
- package/Libraries/Utilities/Dimensions.d.ts +79 -0
- package/Libraries/Utilities/Dimensions.js +2 -2
- package/Libraries/Utilities/Dimensions.win32.js +2 -2
- package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -1
- package/Libraries/Utilities/HMRClient.js +23 -8
- package/Libraries/Utilities/LoadingView.ios.js +1 -1
- package/Libraries/Utilities/NativeAppearance.js +1 -0
- package/Libraries/Utilities/NativeDevLoadingView.js +1 -0
- package/Libraries/Utilities/NativeDevSplitBundleLoader.js +1 -0
- package/Libraries/Utilities/NativeDeviceInfo.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsAndroid.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsIOS.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -0
- package/Libraries/Utilities/PerformanceLoggerContext.js +3 -2
- package/Libraries/Utilities/PixelRatio.d.ts +64 -0
- package/Libraries/Utilities/Platform.android.js +11 -5
- package/Libraries/Utilities/Platform.d.ts +102 -0
- package/Libraries/Utilities/Platform.ios.js +12 -5
- package/Libraries/Utilities/Platform.win32.js +11 -5
- package/Libraries/Utilities/PolyfillFunctions.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +9 -15
- package/Libraries/Utilities/codegenNativeCommands.js +1 -10
- package/Libraries/Utilities/codegenNativeComponent.js +4 -1
- package/Libraries/Utilities/createPerformanceLogger.js +7 -8
- package/Libraries/Utilities/differ/deepDiffer.js +1 -1
- package/Libraries/Utilities/groupByEveryN.js +1 -1
- package/Libraries/Utilities/stringifySafe.js +3 -1
- package/Libraries/Utilities/useColorScheme.js +3 -2
- package/Libraries/Utilities/useRefEffect.js +1 -1
- package/Libraries/Vibration/NativeVibration.js +1 -0
- package/Libraries/Vibration/Vibration.d.ts +43 -0
- package/Libraries/Vibration/Vibration.js +1 -0
- package/Libraries/WebPerformance/NativePerformanceObserver.js +41 -0
- package/Libraries/WebPerformance/PerformanceObserver.js +223 -0
- package/Libraries/WebSocket/NativeWebSocketModule.js +1 -0
- package/Libraries/WebSocket/WebSocket.js +11 -3
- package/Libraries/WebSocket/WebSocketInterceptor.js +1 -1
- package/Libraries/YellowBox/YellowBoxDeprecated.d.ts +19 -0
- package/Libraries/YellowBox/YellowBoxDeprecated.js +2 -3
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -1
- package/Libraries/__tests__/ButtonWin32-test.js +16 -0
- package/Libraries/platform-types.d.ts +25 -0
- package/Libraries/vendor/core/ErrorUtils.d.ts +15 -0
- package/Libraries/vendor/emitter/EventEmitter.d.ts +164 -0
- package/babel.config.js +3 -0
- package/flow/jest.js +2 -2
- package/flow-typed/npm/{react-dom_v16.x.x.js → react-dom_v17.x.x.js} +58 -31
- package/flow-typed/npm/yargs_v17.x.x.js +341 -0
- package/index.js +89 -55
- package/index.win32.js +89 -55
- package/interface.js +8 -0
- package/jest/react-native-env.js +18 -0
- package/jest/renderer.js +2 -2
- package/jest/setup.js +7 -9
- package/jest.config.js +9 -2
- package/overrides.json +40 -101
- package/package.json +34 -33
- package/src/Libraries/Components/TextInput/TextInput.win32.tsx +2 -1
- package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
- package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +2 -1
- package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
- package/src/Libraries/Components/View/ViewWin32.Props.ts +10 -1
- package/src/Libraries/__tests__/__snapshots__/ButtonWin32-test.js.snap +22 -0
- package/src/Libraries/platform-types.d.ts +25 -0
- package/types/index.d.ts +215 -0
- package/IntegrationTests/AsyncStorageTest.js +0 -261
- package/Libraries/Components/MaskedView/MaskedViewIOS.ios.js +0 -93
- package/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js +0 -21
- package/Libraries/Core/setUpSystrace.js +0 -21
- package/Libraries/Image/ImagePickerIOS.js +0 -103
- package/Libraries/Image/NativeImagePickerIOS.js +0 -38
- package/Libraries/Lists/VirtualizedList.win32.js +0 -9
- package/Libraries/Lists/__tests__/CellRenderMask-test.js +0 -179
- package/Libraries/Lists/__tests__/FillRateHelper-test.js +0 -120
- package/Libraries/Lists/__tests__/FlatList-test.js +0 -155
- package/Libraries/Lists/__tests__/SectionList-test.js +0 -109
- package/Libraries/Lists/__tests__/ViewabilityHelper-test.js +0 -440
- package/Libraries/Lists/__tests__/VirtualizeUtils-test.js +0 -91
- package/Libraries/Lists/__tests__/VirtualizedList-test.js +0 -1587
- package/Libraries/Lists/__tests__/VirtualizedSectionList-test.js +0 -269
- package/Libraries/Storage/AsyncStorage.js +0 -385
- package/Libraries/Storage/NativeAsyncLocalStorage.js +0 -44
- package/Libraries/Storage/NativeAsyncSQLiteDBStorage.js +0 -44
- package/Libraries/Utilities/JSDevSupportModule.js +0 -37
- package/Libraries/Utilities/NativeJSDevSupport.js +0 -23
- package/rntypes/BatchedBridge.d.ts +0 -23
- package/rntypes/Devtools.d.ts +0 -20
- package/rntypes/LaunchScreen.d.ts +0 -9
- package/rntypes/globals.d.ts +0 -497
- package/rntypes/index.d.ts +0 -9754
- package/rntypes/legacy-properties.d.ts +0 -238
- package/src/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +0 -427
- package/src/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +0 -391
- package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +0 -4565
- package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +0 -1153
- package/src/rntypes/BatchedBridge.d.ts +0 -23
- package/src/rntypes/Devtools.d.ts +0 -20
- package/src/rntypes/LaunchScreen.d.ts +0 -9
- package/src/rntypes/globals.d.ts +0 -497
- package/src/rntypes/index.d.ts +0 -9754
- package/src/rntypes/legacy-properties.d.ts +0 -238
- package/src/typings-index.ts +0 -37
- package/typings-index.d.ts +0 -23
- package/typings-index.js +0 -47
- package/typings-index.js.map +0 -1
|
@@ -1,1587 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @emails oncall+react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const React = require('react');
|
|
14
|
-
const ReactTestRenderer = require('react-test-renderer');
|
|
15
|
-
|
|
16
|
-
const VirtualizedList = require('../VirtualizedList');
|
|
17
|
-
|
|
18
|
-
describe('VirtualizedList', () => {
|
|
19
|
-
it('renders simple list', () => {
|
|
20
|
-
const component = ReactTestRenderer.create(
|
|
21
|
-
<VirtualizedList
|
|
22
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
23
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
24
|
-
getItem={(data, index) => data[index]}
|
|
25
|
-
getItemCount={data => data.length}
|
|
26
|
-
/>,
|
|
27
|
-
);
|
|
28
|
-
expect(component).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders simple list using ListItemComponent', () => {
|
|
32
|
-
function ListItemComponent({item}) {
|
|
33
|
-
return <item value={item.key} />;
|
|
34
|
-
}
|
|
35
|
-
const component = ReactTestRenderer.create(
|
|
36
|
-
<VirtualizedList
|
|
37
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
38
|
-
ListItemComponent={ListItemComponent}
|
|
39
|
-
getItem={(data, index) => data[index]}
|
|
40
|
-
getItemCount={data => data.length}
|
|
41
|
-
/>,
|
|
42
|
-
);
|
|
43
|
-
expect(component).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('warns if both renderItem or ListItemComponent are specified. Uses ListItemComponent', () => {
|
|
47
|
-
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
|
|
48
|
-
function ListItemComponent({item}) {
|
|
49
|
-
return <item value={item.key} testID={`${item.key}-ListItemComponent`} />;
|
|
50
|
-
}
|
|
51
|
-
const component = ReactTestRenderer.create(
|
|
52
|
-
<VirtualizedList
|
|
53
|
-
data={[{key: 'i1'}]}
|
|
54
|
-
ListItemComponent={ListItemComponent}
|
|
55
|
-
renderItem={({item}) => (
|
|
56
|
-
<item value={item.key} testID={`${item.key}-renderItem`} />
|
|
57
|
-
)}
|
|
58
|
-
getItem={(data, index) => data[index]}
|
|
59
|
-
getItemCount={data => data.length}
|
|
60
|
-
/>,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(console.warn).toBeCalledWith(
|
|
64
|
-
'VirtualizedList: Both ListItemComponent and renderItem props are present. ListItemComponent will take precedence over renderItem.',
|
|
65
|
-
);
|
|
66
|
-
expect(component).toMatchSnapshot();
|
|
67
|
-
console.warn.mockRestore();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('throws if no renderItem or ListItemComponent', () => {
|
|
71
|
-
// Silence the React error boundary warning; we expect an uncaught error.
|
|
72
|
-
const consoleError = console.error;
|
|
73
|
-
jest.spyOn(console, 'error').mockImplementation(message => {
|
|
74
|
-
if (message.startsWith('The above error occurred in the ')) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
consoleError(message);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const componentFactory = () =>
|
|
81
|
-
ReactTestRenderer.create(
|
|
82
|
-
<VirtualizedList
|
|
83
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
84
|
-
getItem={(data, index) => data[index]}
|
|
85
|
-
getItemCount={data => data.length}
|
|
86
|
-
/>,
|
|
87
|
-
);
|
|
88
|
-
expect(componentFactory).toThrow(
|
|
89
|
-
'VirtualizedList: Either ListItemComponent or renderItem props are required but none were found.',
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
console.error.mockRestore();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('renders empty list', () => {
|
|
96
|
-
const component = ReactTestRenderer.create(
|
|
97
|
-
<VirtualizedList
|
|
98
|
-
data={[]}
|
|
99
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
100
|
-
getItem={(data, index) => data[index]}
|
|
101
|
-
getItemCount={data => data.length}
|
|
102
|
-
/>,
|
|
103
|
-
);
|
|
104
|
-
expect(component).toMatchSnapshot();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('renders empty list after batch', () => {
|
|
108
|
-
const component = ReactTestRenderer.create(
|
|
109
|
-
<VirtualizedList
|
|
110
|
-
data={[]}
|
|
111
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
112
|
-
getItem={(data, index) => data[index]}
|
|
113
|
-
getItemCount={data => data.length}
|
|
114
|
-
/>,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
ReactTestRenderer.act(() => {
|
|
118
|
-
simulateLayout(component, {
|
|
119
|
-
viewport: {width: 10, height: 50},
|
|
120
|
-
content: {width: 10, height: 200},
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
performAllBatches();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
expect(component).toMatchSnapshot();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('renders null list', () => {
|
|
130
|
-
const component = ReactTestRenderer.create(
|
|
131
|
-
<VirtualizedList
|
|
132
|
-
data={undefined}
|
|
133
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
134
|
-
getItem={(data, index) => data[index]}
|
|
135
|
-
getItemCount={data => 0}
|
|
136
|
-
/>,
|
|
137
|
-
);
|
|
138
|
-
expect(component).toMatchSnapshot();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('renders empty list with empty component', () => {
|
|
142
|
-
const component = ReactTestRenderer.create(
|
|
143
|
-
<VirtualizedList
|
|
144
|
-
data={[]}
|
|
145
|
-
ListEmptyComponent={() => <empty />}
|
|
146
|
-
ListFooterComponent={() => <footer />}
|
|
147
|
-
ListHeaderComponent={() => <header />}
|
|
148
|
-
getItem={(data, index) => data[index]}
|
|
149
|
-
getItemCount={data => data.length}
|
|
150
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
151
|
-
/>,
|
|
152
|
-
);
|
|
153
|
-
expect(component).toMatchSnapshot();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('renders list with empty component', () => {
|
|
157
|
-
const component = ReactTestRenderer.create(
|
|
158
|
-
<VirtualizedList
|
|
159
|
-
data={[{key: 'hello'}]}
|
|
160
|
-
ListEmptyComponent={() => <empty />}
|
|
161
|
-
getItem={(data, index) => data[index]}
|
|
162
|
-
getItemCount={data => data.length}
|
|
163
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
164
|
-
/>,
|
|
165
|
-
);
|
|
166
|
-
expect(component).toMatchSnapshot();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('renders all the bells and whistles', () => {
|
|
170
|
-
const component = ReactTestRenderer.create(
|
|
171
|
-
<VirtualizedList
|
|
172
|
-
ItemSeparatorComponent={() => <separator />}
|
|
173
|
-
ListEmptyComponent={() => <empty />}
|
|
174
|
-
ListFooterComponent={() => <footer />}
|
|
175
|
-
ListHeaderComponent={() => <header />}
|
|
176
|
-
data={new Array(5).fill().map((_, ii) => ({id: String(ii)}))}
|
|
177
|
-
getItem={(data, index) => data[index]}
|
|
178
|
-
getItemCount={data => data.length}
|
|
179
|
-
getItemLayout={({index}) => ({length: 50, offset: index * 50})}
|
|
180
|
-
inverted={true}
|
|
181
|
-
keyExtractor={(item, index) => item.id}
|
|
182
|
-
onRefresh={jest.fn()}
|
|
183
|
-
refreshing={false}
|
|
184
|
-
renderItem={({item}) => <item value={item.id} />}
|
|
185
|
-
/>,
|
|
186
|
-
);
|
|
187
|
-
expect(component).toMatchSnapshot();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('test getItem functionality where data is not an Array', () => {
|
|
191
|
-
const component = ReactTestRenderer.create(
|
|
192
|
-
<VirtualizedList
|
|
193
|
-
data={new Map([['id_0', {key: 'item_0'}]])}
|
|
194
|
-
getItem={(data, index) => data.get('id_' + index)}
|
|
195
|
-
getItemCount={(data: Map) => data.size}
|
|
196
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
197
|
-
/>,
|
|
198
|
-
);
|
|
199
|
-
expect(component).toMatchSnapshot();
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('handles separators correctly', () => {
|
|
203
|
-
const infos = [];
|
|
204
|
-
const component = ReactTestRenderer.create(
|
|
205
|
-
<VirtualizedList
|
|
206
|
-
ItemSeparatorComponent={props => <separator {...props} />}
|
|
207
|
-
data={[{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]}
|
|
208
|
-
renderItem={info => {
|
|
209
|
-
infos.push(info);
|
|
210
|
-
return <item title={info.item.key} />;
|
|
211
|
-
}}
|
|
212
|
-
getItem={(data, index) => data[index]}
|
|
213
|
-
getItemCount={data => data.length}
|
|
214
|
-
/>,
|
|
215
|
-
);
|
|
216
|
-
expect(component).toMatchSnapshot();
|
|
217
|
-
infos[1].separators.highlight();
|
|
218
|
-
expect(component).toMatchSnapshot();
|
|
219
|
-
infos[2].separators.updateProps('leading', {press: true});
|
|
220
|
-
expect(component).toMatchSnapshot();
|
|
221
|
-
infos[1].separators.unhighlight();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('handles nested lists', () => {
|
|
225
|
-
const component = ReactTestRenderer.create(
|
|
226
|
-
<VirtualizedList
|
|
227
|
-
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
228
|
-
renderItem={outerInfo => (
|
|
229
|
-
<VirtualizedList
|
|
230
|
-
data={[
|
|
231
|
-
{key: outerInfo.item.key + ':inner0'},
|
|
232
|
-
{key: outerInfo.item.key + ':inner1'},
|
|
233
|
-
]}
|
|
234
|
-
horizontal={outerInfo.item.key === 'outer1'}
|
|
235
|
-
renderItem={innerInfo => {
|
|
236
|
-
return <item title={innerInfo.item.key} />;
|
|
237
|
-
}}
|
|
238
|
-
getItem={(data, index) => data[index]}
|
|
239
|
-
getItemCount={data => data.length}
|
|
240
|
-
/>
|
|
241
|
-
)}
|
|
242
|
-
getItem={(data, index) => data[index]}
|
|
243
|
-
getItemCount={data => data.length}
|
|
244
|
-
/>,
|
|
245
|
-
);
|
|
246
|
-
expect(component).toMatchSnapshot();
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('returns the viewableItems correctly in the onViewableItemsChanged callback after changing the data', () => {
|
|
250
|
-
const ITEM_HEIGHT = 800;
|
|
251
|
-
let data = [{key: 'i1'}, {key: 'i2'}, {key: 'i3'}];
|
|
252
|
-
const nativeEvent = {
|
|
253
|
-
contentOffset: {y: 0, x: 0},
|
|
254
|
-
layoutMeasurement: {width: 300, height: 600},
|
|
255
|
-
contentSize: {width: 300, height: data.length * ITEM_HEIGHT},
|
|
256
|
-
zoomScale: 1,
|
|
257
|
-
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
|
|
258
|
-
};
|
|
259
|
-
const onViewableItemsChanged = jest.fn();
|
|
260
|
-
const props = {
|
|
261
|
-
data,
|
|
262
|
-
renderItem: ({item}) => <item value={item.key} />,
|
|
263
|
-
getItem: (items, index) => items[index],
|
|
264
|
-
getItemCount: items => items.length,
|
|
265
|
-
getItemLayout: (items, index) => ({
|
|
266
|
-
length: ITEM_HEIGHT,
|
|
267
|
-
offset: ITEM_HEIGHT * index,
|
|
268
|
-
index,
|
|
269
|
-
}),
|
|
270
|
-
onViewableItemsChanged,
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const component = ReactTestRenderer.create(<VirtualizedList {...props} />);
|
|
274
|
-
|
|
275
|
-
const instance = component.getInstance();
|
|
276
|
-
|
|
277
|
-
instance._onScrollBeginDrag({nativeEvent});
|
|
278
|
-
instance._onScroll({
|
|
279
|
-
timeStamp: 1000,
|
|
280
|
-
nativeEvent,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
expect(onViewableItemsChanged).toHaveBeenCalledTimes(1);
|
|
284
|
-
expect(onViewableItemsChanged).toHaveBeenLastCalledWith(
|
|
285
|
-
expect.objectContaining({
|
|
286
|
-
viewableItems: [expect.objectContaining({isViewable: true, key: 'i1'})],
|
|
287
|
-
}),
|
|
288
|
-
);
|
|
289
|
-
data = [{key: 'i4'}, ...data];
|
|
290
|
-
component.update(<VirtualizedList {...props} data={data} />);
|
|
291
|
-
|
|
292
|
-
instance._onScroll({
|
|
293
|
-
timeStamp: 2000,
|
|
294
|
-
nativeEvent: {
|
|
295
|
-
...nativeEvent,
|
|
296
|
-
contentOffset: {y: 100, x: 0},
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
expect(onViewableItemsChanged).toHaveBeenCalledTimes(2);
|
|
301
|
-
expect(onViewableItemsChanged).toHaveBeenLastCalledWith(
|
|
302
|
-
expect.objectContaining({
|
|
303
|
-
viewableItems: [expect.objectContaining({isViewable: true, key: 'i4'})],
|
|
304
|
-
}),
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('getScrollRef for case where it returns a ScrollView', () => {
|
|
309
|
-
const listRef = React.createRef(null);
|
|
310
|
-
|
|
311
|
-
ReactTestRenderer.create(
|
|
312
|
-
<VirtualizedList
|
|
313
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
314
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
315
|
-
getItem={(data, index) => data[index]}
|
|
316
|
-
getItemCount={data => data.length}
|
|
317
|
-
ref={listRef}
|
|
318
|
-
/>,
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
const scrollRef = listRef.current.getScrollRef();
|
|
322
|
-
|
|
323
|
-
// This is checking if the ref acts like a ScrollView. If we had an
|
|
324
|
-
// `isScrollView(ref)` method, that would be preferred.
|
|
325
|
-
expect(scrollRef.scrollTo).toBeInstanceOf(jest.fn().constructor);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it('getScrollRef for case where it returns a View', () => {
|
|
329
|
-
const listRef = React.createRef(null);
|
|
330
|
-
|
|
331
|
-
ReactTestRenderer.create(
|
|
332
|
-
<VirtualizedList
|
|
333
|
-
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
334
|
-
renderItem={outerInfo => (
|
|
335
|
-
<VirtualizedList
|
|
336
|
-
data={[
|
|
337
|
-
{key: outerInfo.item.key + ':inner0'},
|
|
338
|
-
{key: outerInfo.item.key + ':inner1'},
|
|
339
|
-
]}
|
|
340
|
-
renderItem={innerInfo => {
|
|
341
|
-
return <item title={innerInfo.item.key} />;
|
|
342
|
-
}}
|
|
343
|
-
getItem={(data, index) => data[index]}
|
|
344
|
-
getItemCount={data => data.length}
|
|
345
|
-
ref={listRef}
|
|
346
|
-
/>
|
|
347
|
-
)}
|
|
348
|
-
getItem={(data, index) => data[index]}
|
|
349
|
-
getItemCount={data => data.length}
|
|
350
|
-
/>,
|
|
351
|
-
);
|
|
352
|
-
const scrollRef = listRef.current.getScrollRef();
|
|
353
|
-
|
|
354
|
-
// This is checking if the ref acts like a host component. If we had an
|
|
355
|
-
// `isHostComponent(ref)` method, that would be preferred.
|
|
356
|
-
expect(scrollRef.measure).toBeInstanceOf(jest.fn().constructor);
|
|
357
|
-
expect(scrollRef.measureLayout).toBeInstanceOf(jest.fn().constructor);
|
|
358
|
-
expect(scrollRef.measureInWindow).toBeInstanceOf(jest.fn().constructor);
|
|
359
|
-
});
|
|
360
|
-
it('does not call onEndReached when onContentSizeChange happens after onLayout', () => {
|
|
361
|
-
const ITEM_HEIGHT = 40;
|
|
362
|
-
const layout = {width: 300, height: 600};
|
|
363
|
-
let data = Array(20)
|
|
364
|
-
.fill()
|
|
365
|
-
.map((_, index) => ({key: `key-${index}`}));
|
|
366
|
-
const onEndReached = jest.fn();
|
|
367
|
-
const props = {
|
|
368
|
-
data,
|
|
369
|
-
initialNumToRender: 10,
|
|
370
|
-
onEndReachedThreshold: 2,
|
|
371
|
-
windowSize: 21,
|
|
372
|
-
renderItem: ({item}) => <item value={item.key} />,
|
|
373
|
-
getItem: (items, index) => items[index],
|
|
374
|
-
getItemCount: items => items.length,
|
|
375
|
-
getItemLayout: (items, index) => ({
|
|
376
|
-
length: ITEM_HEIGHT,
|
|
377
|
-
offset: ITEM_HEIGHT * index,
|
|
378
|
-
index,
|
|
379
|
-
}),
|
|
380
|
-
onEndReached,
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const component = ReactTestRenderer.create(<VirtualizedList {...props} />);
|
|
384
|
-
|
|
385
|
-
const instance = component.getInstance();
|
|
386
|
-
|
|
387
|
-
instance._onLayout({nativeEvent: {layout, zoomScale: 1}});
|
|
388
|
-
|
|
389
|
-
const initialContentHeight = props.initialNumToRender * ITEM_HEIGHT;
|
|
390
|
-
|
|
391
|
-
// We want to test the unusual case of onContentSizeChange firing after
|
|
392
|
-
// onLayout, which can cause https://github.com/facebook/react-native/issues/16067
|
|
393
|
-
instance._onContentSizeChange(300, initialContentHeight);
|
|
394
|
-
instance._onContentSizeChange(300, data.length * ITEM_HEIGHT);
|
|
395
|
-
performAllBatches();
|
|
396
|
-
|
|
397
|
-
expect(onEndReached).not.toHaveBeenCalled();
|
|
398
|
-
|
|
399
|
-
instance._onScroll({
|
|
400
|
-
timeStamp: 1000,
|
|
401
|
-
nativeEvent: {
|
|
402
|
-
contentOffset: {y: initialContentHeight, x: 0},
|
|
403
|
-
layoutMeasurement: layout,
|
|
404
|
-
contentSize: {...layout, height: data.length * ITEM_HEIGHT},
|
|
405
|
-
zoomScale: 1,
|
|
406
|
-
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
|
|
407
|
-
},
|
|
408
|
-
});
|
|
409
|
-
performAllBatches();
|
|
410
|
-
|
|
411
|
-
expect(onEndReached).toHaveBeenCalled();
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it('provides a trace when a listKey collision occurs', () => {
|
|
415
|
-
const errors = [];
|
|
416
|
-
jest.spyOn(console, 'error').mockImplementation((...args) => {
|
|
417
|
-
// Silence the DEV-only React error boundary warning.
|
|
418
|
-
if ((args[0] || '').startsWith('The above error occurred in the ')) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
errors.push(args);
|
|
422
|
-
});
|
|
423
|
-
const commonProps = {
|
|
424
|
-
data: [{key: 'cell0'}],
|
|
425
|
-
getItem: (data, index) => data[index],
|
|
426
|
-
getItemCount: data => data.length,
|
|
427
|
-
renderItem: ({item}) => <item value={item.key} />,
|
|
428
|
-
};
|
|
429
|
-
try {
|
|
430
|
-
ReactTestRenderer.create(
|
|
431
|
-
<VirtualizedList
|
|
432
|
-
{...commonProps}
|
|
433
|
-
horizontal={false}
|
|
434
|
-
listKey="level0"
|
|
435
|
-
renderItem={() => (
|
|
436
|
-
<VirtualizedList
|
|
437
|
-
{...commonProps}
|
|
438
|
-
horizontal={true}
|
|
439
|
-
listKey="level1"
|
|
440
|
-
renderItem={() => (
|
|
441
|
-
<>
|
|
442
|
-
{/* Force a collision */}
|
|
443
|
-
<VirtualizedList
|
|
444
|
-
{...commonProps}
|
|
445
|
-
horizontal={true}
|
|
446
|
-
listKey="level2"
|
|
447
|
-
/>
|
|
448
|
-
<VirtualizedList
|
|
449
|
-
{...commonProps}
|
|
450
|
-
horizontal={true}
|
|
451
|
-
listKey="level2"
|
|
452
|
-
/>
|
|
453
|
-
</>
|
|
454
|
-
)}
|
|
455
|
-
/>
|
|
456
|
-
)}
|
|
457
|
-
/>,
|
|
458
|
-
);
|
|
459
|
-
expect(errors).toMatchInlineSnapshot(`
|
|
460
|
-
Array [
|
|
461
|
-
Array [
|
|
462
|
-
"A VirtualizedList contains a cell which itself contains more than one VirtualizedList of the same orientation as the parent list. You must pass a unique listKey prop to each sibling list.
|
|
463
|
-
|
|
464
|
-
VirtualizedList trace:
|
|
465
|
-
Child (horizontal):
|
|
466
|
-
listKey: level2
|
|
467
|
-
cellKey: cell0
|
|
468
|
-
Parent (horizontal):
|
|
469
|
-
listKey: level1
|
|
470
|
-
cellKey: cell0
|
|
471
|
-
Parent (vertical):
|
|
472
|
-
listKey: level0
|
|
473
|
-
cellKey: rootList",
|
|
474
|
-
],
|
|
475
|
-
]
|
|
476
|
-
`);
|
|
477
|
-
} finally {
|
|
478
|
-
console.error.mockRestore();
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
it('throws if using scrollToIndex with index less than 0', () => {
|
|
483
|
-
const component = ReactTestRenderer.create(
|
|
484
|
-
<VirtualizedList
|
|
485
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
486
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
487
|
-
getItem={(data, index) => data[index]}
|
|
488
|
-
getItemCount={data => data.length}
|
|
489
|
-
/>,
|
|
490
|
-
);
|
|
491
|
-
const instance = component.getInstance();
|
|
492
|
-
|
|
493
|
-
expect(() => instance.scrollToIndex({index: -1})).toThrow(
|
|
494
|
-
'scrollToIndex out of range: requested index -1 but minimum is 0',
|
|
495
|
-
);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it('throws if using scrollToIndex when item length is less than 1', () => {
|
|
499
|
-
const component = ReactTestRenderer.create(
|
|
500
|
-
<VirtualizedList
|
|
501
|
-
data={[]}
|
|
502
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
503
|
-
getItem={(data, index) => data[index]}
|
|
504
|
-
getItemCount={data => data.length}
|
|
505
|
-
/>,
|
|
506
|
-
);
|
|
507
|
-
const instance = component.getInstance();
|
|
508
|
-
|
|
509
|
-
expect(() => instance.scrollToIndex({index: 1})).toThrow(
|
|
510
|
-
'scrollToIndex out of range: item length 0 but minimum is 1',
|
|
511
|
-
);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
it('throws if using scrollToIndex when requested index is bigger than or equal to item length', () => {
|
|
515
|
-
const component = ReactTestRenderer.create(
|
|
516
|
-
<VirtualizedList
|
|
517
|
-
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
518
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
519
|
-
getItem={(data, index) => data[index]}
|
|
520
|
-
getItemCount={data => data.length}
|
|
521
|
-
/>,
|
|
522
|
-
);
|
|
523
|
-
const instance = component.getInstance();
|
|
524
|
-
|
|
525
|
-
expect(() => instance.scrollToIndex({index: 3})).toThrow(
|
|
526
|
-
'scrollToIndex out of range: requested index 3 is out of 0 to 2',
|
|
527
|
-
);
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
it('forwards correct stickyHeaderIndices when all in initial render window', () => {
|
|
531
|
-
const items = generateItemsStickyEveryN(10, 3);
|
|
532
|
-
const ITEM_HEIGHT = 10;
|
|
533
|
-
|
|
534
|
-
const component = ReactTestRenderer.create(
|
|
535
|
-
<VirtualizedList
|
|
536
|
-
initialNumToRender={10}
|
|
537
|
-
{...baseItemProps(items)}
|
|
538
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
539
|
-
/>,
|
|
540
|
-
);
|
|
541
|
-
|
|
542
|
-
// The initial render is specified to be the length of items provided.
|
|
543
|
-
// Expect that all sticky items (1 every 3) are passed to the underlying
|
|
544
|
-
// scrollview.
|
|
545
|
-
expect(component).toMatchSnapshot();
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('forwards correct stickyHeaderIndices when ListHeaderComponent present', () => {
|
|
549
|
-
const items = generateItemsStickyEveryN(10, 3);
|
|
550
|
-
const ITEM_HEIGHT = 10;
|
|
551
|
-
|
|
552
|
-
const component = ReactTestRenderer.create(
|
|
553
|
-
<VirtualizedList
|
|
554
|
-
ListHeaderComponent={() => React.createElement('Header')}
|
|
555
|
-
initialNumToRender={10}
|
|
556
|
-
{...baseItemProps(items)}
|
|
557
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
558
|
-
/>,
|
|
559
|
-
);
|
|
560
|
-
|
|
561
|
-
// The initial render is specified to be the length of items provided.
|
|
562
|
-
// Expect that all sticky items (1 every 3) are passed to the underlying
|
|
563
|
-
// scrollview, indices offset by 1 to account for the the header component.
|
|
564
|
-
expect(component).toMatchSnapshot();
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
it('forwards correct stickyHeaderIndices when partially in initial render window', () => {
|
|
568
|
-
const items = generateItemsStickyEveryN(10, 3);
|
|
569
|
-
|
|
570
|
-
const ITEM_HEIGHT = 10;
|
|
571
|
-
|
|
572
|
-
const component = ReactTestRenderer.create(
|
|
573
|
-
<VirtualizedList
|
|
574
|
-
initialNumToRender={5}
|
|
575
|
-
{...baseItemProps(items)}
|
|
576
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
577
|
-
/>,
|
|
578
|
-
);
|
|
579
|
-
|
|
580
|
-
// The initial render is specified to be half the length of items provided.
|
|
581
|
-
// Expect that all sticky items of index < 5 are passed to the underlying
|
|
582
|
-
// scrollview.
|
|
583
|
-
expect(component).toMatchSnapshot();
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
it('renders sticky headers in viewport on batched render', () => {
|
|
587
|
-
const items = generateItemsStickyEveryN(10, 3);
|
|
588
|
-
const ITEM_HEIGHT = 10;
|
|
589
|
-
|
|
590
|
-
let component;
|
|
591
|
-
ReactTestRenderer.act(() => {
|
|
592
|
-
component = ReactTestRenderer.create(
|
|
593
|
-
<VirtualizedList
|
|
594
|
-
initialNumToRender={1}
|
|
595
|
-
windowSize={1}
|
|
596
|
-
{...baseItemProps(items)}
|
|
597
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
598
|
-
/>,
|
|
599
|
-
);
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
ReactTestRenderer.act(() => {
|
|
603
|
-
simulateLayout(component, {
|
|
604
|
-
viewport: {width: 10, height: 50},
|
|
605
|
-
content: {width: 10, height: 100},
|
|
606
|
-
});
|
|
607
|
-
performAllBatches();
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
// A windowSize of 1 means we will render just the viewport height (50dip).
|
|
611
|
-
// Expect 5 10dip items to eventually be rendered, with sticky headers in
|
|
612
|
-
// the first 5 propagated.
|
|
613
|
-
expect(component).toMatchSnapshot();
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it('keeps sticky headers above viewport visualized', () => {
|
|
617
|
-
const items = generateItemsStickyEveryN(20, 3);
|
|
618
|
-
const ITEM_HEIGHT = 10;
|
|
619
|
-
|
|
620
|
-
let component;
|
|
621
|
-
ReactTestRenderer.act(() => {
|
|
622
|
-
component = ReactTestRenderer.create(
|
|
623
|
-
<VirtualizedList
|
|
624
|
-
initialNumToRender={1}
|
|
625
|
-
windowSize={1}
|
|
626
|
-
{...baseItemProps(items)}
|
|
627
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
628
|
-
/>,
|
|
629
|
-
);
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
ReactTestRenderer.act(() => {
|
|
633
|
-
simulateLayout(component, {
|
|
634
|
-
viewport: {width: 10, height: 50},
|
|
635
|
-
content: {width: 10, height: 200},
|
|
636
|
-
});
|
|
637
|
-
performAllBatches();
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
ReactTestRenderer.act(() => {
|
|
641
|
-
simulateScroll(component, {x: 0, y: 150});
|
|
642
|
-
performAllBatches();
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
// Scroll to the bottom 50 dip (last five items) of the content. Expect the
|
|
646
|
-
// last five items to be rendered (possibly more if realization window is
|
|
647
|
-
// larger), along with the most recent sticky header above the realization
|
|
648
|
-
// region, even though they are out of the viewport window in layout
|
|
649
|
-
// coordinates. This is because they will remain rendered even once
|
|
650
|
-
// scrolled-past in layout space.
|
|
651
|
-
expect(component).toMatchSnapshot();
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
it('unmounts sticky headers moved below viewport', () => {
|
|
656
|
-
const items = generateItemsStickyEveryN(20, 3);
|
|
657
|
-
const ITEM_HEIGHT = 10;
|
|
658
|
-
|
|
659
|
-
let component;
|
|
660
|
-
ReactTestRenderer.act(() => {
|
|
661
|
-
component = ReactTestRenderer.create(
|
|
662
|
-
<VirtualizedList
|
|
663
|
-
initialNumToRender={1}
|
|
664
|
-
windowSize={1}
|
|
665
|
-
{...baseItemProps(items)}
|
|
666
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
667
|
-
/>,
|
|
668
|
-
);
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
ReactTestRenderer.act(() => {
|
|
672
|
-
simulateLayout(component, {
|
|
673
|
-
viewport: {width: 10, height: 50},
|
|
674
|
-
content: {width: 10, height: 200},
|
|
675
|
-
});
|
|
676
|
-
performAllBatches();
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
ReactTestRenderer.act(() => {
|
|
680
|
-
simulateScroll(component, {x: 0, y: 150});
|
|
681
|
-
performAllBatches();
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
ReactTestRenderer.act(() => {
|
|
685
|
-
simulateScroll(component, {x: 0, y: 0});
|
|
686
|
-
performAllBatches();
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
// Scroll to the bottom 50 dip (last five items) of the content, then back up
|
|
690
|
-
// to the first 5. Ensure that sticky items are unmounted once they are below
|
|
691
|
-
// the render area.
|
|
692
|
-
expect(component).toMatchSnapshot();
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
it('renders offset cells in initial render when initialScrollIndex set', () => {
|
|
696
|
-
const items = generateItems(10);
|
|
697
|
-
const ITEM_HEIGHT = 10;
|
|
698
|
-
|
|
699
|
-
const component = ReactTestRenderer.create(
|
|
700
|
-
<VirtualizedList
|
|
701
|
-
initialScrollIndex={4}
|
|
702
|
-
initialNumToRender={4}
|
|
703
|
-
{...baseItemProps(items)}
|
|
704
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
705
|
-
/>,
|
|
706
|
-
);
|
|
707
|
-
|
|
708
|
-
// Check that the first render respects initialScrollIndex
|
|
709
|
-
expect(component).toMatchSnapshot();
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
it('does not over-render when there is less than initialNumToRender cells', () => {
|
|
713
|
-
const items = generateItems(10);
|
|
714
|
-
const ITEM_HEIGHT = 10;
|
|
715
|
-
|
|
716
|
-
const component = ReactTestRenderer.create(
|
|
717
|
-
<VirtualizedList
|
|
718
|
-
initialScrollIndex={4}
|
|
719
|
-
initialNumToRender={20}
|
|
720
|
-
{...baseItemProps(items)}
|
|
721
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
722
|
-
/>,
|
|
723
|
-
);
|
|
724
|
-
|
|
725
|
-
// Check that the first render clamps to the last item when intialNumToRender
|
|
726
|
-
// goes over it.
|
|
727
|
-
expect(component).toMatchSnapshot();
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
it('retains intitial render if initialScrollIndex == 0', () => {
|
|
731
|
-
const items = generateItems(20);
|
|
732
|
-
const ITEM_HEIGHT = 10;
|
|
733
|
-
|
|
734
|
-
let component;
|
|
735
|
-
ReactTestRenderer.act(() => {
|
|
736
|
-
component = ReactTestRenderer.create(
|
|
737
|
-
<VirtualizedList
|
|
738
|
-
initialNumToRender={5}
|
|
739
|
-
initialScrollIndex={0}
|
|
740
|
-
windowSize={1}
|
|
741
|
-
{...baseItemProps(items)}
|
|
742
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
743
|
-
/>,
|
|
744
|
-
);
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
ReactTestRenderer.act(() => {
|
|
748
|
-
simulateLayout(component, {
|
|
749
|
-
viewport: {width: 10, height: 50},
|
|
750
|
-
content: {width: 10, height: 200},
|
|
751
|
-
});
|
|
752
|
-
performAllBatches();
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
ReactTestRenderer.act(() => {
|
|
756
|
-
simulateScroll(component, {x: 0, y: 150});
|
|
757
|
-
performAllBatches();
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// If initialScrollIndex is 0 (the default), we should never unmount the top
|
|
761
|
-
// initialNumToRender as part of the "scroll to top optimization", even after
|
|
762
|
-
// scrolling to the bottom five items.
|
|
763
|
-
expect(component).toMatchSnapshot();
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
it('discards intitial render if initialScrollIndex != 0', () => {
|
|
767
|
-
const items = generateItems(20);
|
|
768
|
-
const ITEM_HEIGHT = 10;
|
|
769
|
-
|
|
770
|
-
let component;
|
|
771
|
-
ReactTestRenderer.act(() => {
|
|
772
|
-
component = ReactTestRenderer.create(
|
|
773
|
-
<VirtualizedList
|
|
774
|
-
initialScrollIndex={5}
|
|
775
|
-
initialNumToRender={5}
|
|
776
|
-
windowSize={1}
|
|
777
|
-
{...baseItemProps(items)}
|
|
778
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
779
|
-
/>,
|
|
780
|
-
);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
ReactTestRenderer.act(() => {
|
|
784
|
-
simulateLayout(component, {
|
|
785
|
-
viewport: {width: 10, height: 50},
|
|
786
|
-
content: {width: 10, height: 200},
|
|
787
|
-
});
|
|
788
|
-
performAllBatches();
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
ReactTestRenderer.act(() => {
|
|
792
|
-
simulateScroll(component, {x: 0, y: 150});
|
|
793
|
-
performAllBatches();
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
// If initialScrollIndex is not 0, we do not enable retaining initial render
|
|
797
|
-
// as part of "scroll to top" optimization.
|
|
798
|
-
expect(component).toMatchSnapshot();
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
it('expands render area by maxToRenderPerBatch on tick', () => {
|
|
802
|
-
const items = generateItems(20);
|
|
803
|
-
const ITEM_HEIGHT = 10;
|
|
804
|
-
|
|
805
|
-
const props = {
|
|
806
|
-
initialNumToRender: 5,
|
|
807
|
-
maxToRenderPerBatch: 2,
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
let component;
|
|
811
|
-
ReactTestRenderer.act(() => {
|
|
812
|
-
component = ReactTestRenderer.create(
|
|
813
|
-
<VirtualizedList
|
|
814
|
-
{...baseItemProps(items)}
|
|
815
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
816
|
-
{...props}
|
|
817
|
-
/>,
|
|
818
|
-
);
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
ReactTestRenderer.act(() => {
|
|
822
|
-
simulateLayout(component, {
|
|
823
|
-
viewport: {width: 10, height: 50},
|
|
824
|
-
content: {width: 10, height: 200},
|
|
825
|
-
});
|
|
826
|
-
performNextBatch();
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
// We start by rendering 5 items in the initial render, but have default
|
|
830
|
-
// windowSize, enabling eventual rendering up to 20 viewports worth of
|
|
831
|
-
// content. We limit this to rendering 2 items per-batch via
|
|
832
|
-
// maxToRenderPerBatch, so we should only have 7 items rendered after the
|
|
833
|
-
// initial timer tick.
|
|
834
|
-
expect(component).toMatchSnapshot();
|
|
835
|
-
});
|
|
836
|
-
|
|
837
|
-
it('does not adjust render area until content area layed out', () => {
|
|
838
|
-
const items = generateItems(20);
|
|
839
|
-
const ITEM_HEIGHT = 10;
|
|
840
|
-
|
|
841
|
-
let component;
|
|
842
|
-
|
|
843
|
-
ReactTestRenderer.act(() => {
|
|
844
|
-
component = ReactTestRenderer.create(
|
|
845
|
-
<VirtualizedList
|
|
846
|
-
initialNumToRender={5}
|
|
847
|
-
windowSize={10}
|
|
848
|
-
{...baseItemProps(items)}
|
|
849
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
850
|
-
/>,
|
|
851
|
-
);
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
ReactTestRenderer.act(() => {
|
|
855
|
-
simulateViewportLayout(component, {width: 10, height: 50});
|
|
856
|
-
performAllBatches();
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
// We should not start layout-based logic to expand rendered area until
|
|
860
|
-
// content is layed out. Expect only the 5 initial items to be rendered after
|
|
861
|
-
// processing all batch work, even though the windowSize allows for more.
|
|
862
|
-
expect(component).toMatchSnapshot();
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
it('adjusts render area with non-zero initialScrollIndex', () => {
|
|
866
|
-
const items = generateItems(20);
|
|
867
|
-
const ITEM_HEIGHT = 10;
|
|
868
|
-
|
|
869
|
-
let component;
|
|
870
|
-
ReactTestRenderer.act(() => {
|
|
871
|
-
component = ReactTestRenderer.create(
|
|
872
|
-
<VirtualizedList
|
|
873
|
-
initialNumToRender={5}
|
|
874
|
-
initialScrollIndex={1}
|
|
875
|
-
windowSize={10}
|
|
876
|
-
maxToRenderPerBatch={10}
|
|
877
|
-
{...baseItemProps(items)}
|
|
878
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
879
|
-
/>,
|
|
880
|
-
);
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
ReactTestRenderer.act(() => {
|
|
884
|
-
simulateLayout(component, {
|
|
885
|
-
viewport: {width: 10, height: 50},
|
|
886
|
-
content: {width: 10, height: 200},
|
|
887
|
-
});
|
|
888
|
-
simulateScroll(component, {x: 0, y: 10}); // simulate scroll offset for initialScrollIndex
|
|
889
|
-
|
|
890
|
-
performAllBatches();
|
|
891
|
-
});
|
|
892
|
-
|
|
893
|
-
// We should expand the render area after receiving a message indcating we
|
|
894
|
-
// arrived at initialScrollIndex.
|
|
895
|
-
expect(component).toMatchSnapshot();
|
|
896
|
-
});
|
|
897
|
-
|
|
898
|
-
it('renders new items when data is updated with non-zero initialScrollIndex', () => {
|
|
899
|
-
const items = generateItems(2);
|
|
900
|
-
const ITEM_HEIGHT = 10;
|
|
901
|
-
|
|
902
|
-
let component;
|
|
903
|
-
ReactTestRenderer.act(() => {
|
|
904
|
-
component = ReactTestRenderer.create(
|
|
905
|
-
<VirtualizedList
|
|
906
|
-
initialNumToRender={5}
|
|
907
|
-
initialScrollIndex={1}
|
|
908
|
-
windowSize={10}
|
|
909
|
-
maxToRenderPerBatch={10}
|
|
910
|
-
{...baseItemProps(items)}
|
|
911
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
912
|
-
/>,
|
|
913
|
-
);
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
ReactTestRenderer.act(() => {
|
|
917
|
-
simulateLayout(component, {
|
|
918
|
-
viewport: {width: 10, height: 20},
|
|
919
|
-
content: {width: 10, height: 20},
|
|
920
|
-
});
|
|
921
|
-
performAllBatches();
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
const newItems = generateItems(4);
|
|
925
|
-
|
|
926
|
-
ReactTestRenderer.act(() => {
|
|
927
|
-
component.update(
|
|
928
|
-
<VirtualizedList
|
|
929
|
-
initialNumToRender={5}
|
|
930
|
-
initialScrollIndex={1}
|
|
931
|
-
windowSize={10}
|
|
932
|
-
maxToRenderPerBatch={10}
|
|
933
|
-
{...baseItemProps(newItems)}
|
|
934
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
935
|
-
/>,
|
|
936
|
-
);
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
ReactTestRenderer.act(() => {
|
|
940
|
-
performAllBatches();
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// We expect all the items to be rendered
|
|
944
|
-
expect(component).toMatchSnapshot();
|
|
945
|
-
});
|
|
946
|
-
|
|
947
|
-
it('renders initialNumToRender cells when virtualization disabled', () => {
|
|
948
|
-
const items = generateItems(10);
|
|
949
|
-
const ITEM_HEIGHT = 10;
|
|
950
|
-
|
|
951
|
-
const component = ReactTestRenderer.create(
|
|
952
|
-
<VirtualizedList
|
|
953
|
-
initialNumToRender={5}
|
|
954
|
-
initialScrollIndex={1}
|
|
955
|
-
disableVirtualization
|
|
956
|
-
{...baseItemProps(items)}
|
|
957
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
958
|
-
/>,
|
|
959
|
-
);
|
|
960
|
-
|
|
961
|
-
// We should render initialNumToRender items with no spacers on initial render
|
|
962
|
-
// when virtualization is disabled
|
|
963
|
-
expect(component).toMatchSnapshot();
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
it('renders no spacers up to initialScrollIndex on first render when virtualization disabled', () => {
|
|
967
|
-
const items = generateItems(10);
|
|
968
|
-
const ITEM_HEIGHT = 10;
|
|
969
|
-
|
|
970
|
-
let component;
|
|
971
|
-
ReactTestRenderer.act(() => {
|
|
972
|
-
component = ReactTestRenderer.create(
|
|
973
|
-
<VirtualizedList
|
|
974
|
-
initialNumToRender={2}
|
|
975
|
-
initialScrollIndex={4}
|
|
976
|
-
maxToRenderPerBatch={1}
|
|
977
|
-
disableVirtualization
|
|
978
|
-
{...baseItemProps(items)}
|
|
979
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
980
|
-
/>,
|
|
981
|
-
);
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
// There should be no spacers present in an offset initial render with
|
|
985
|
-
// virtualiztion disabled. Only initialNumToRender items starting at
|
|
986
|
-
// initialScrollIndex.
|
|
987
|
-
expect(component).toMatchSnapshot();
|
|
988
|
-
});
|
|
989
|
-
|
|
990
|
-
it('expands first in viewport to render up to maxToRenderPerBatch on initial render', () => {
|
|
991
|
-
const items = generateItems(10);
|
|
992
|
-
const ITEM_HEIGHT = 10;
|
|
993
|
-
|
|
994
|
-
let component;
|
|
995
|
-
ReactTestRenderer.act(() => {
|
|
996
|
-
component = ReactTestRenderer.create(
|
|
997
|
-
<VirtualizedList
|
|
998
|
-
initialNumToRender={2}
|
|
999
|
-
initialScrollIndex={4}
|
|
1000
|
-
maxToRenderPerBatch={10}
|
|
1001
|
-
{...baseItemProps(items)}
|
|
1002
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1003
|
-
/>,
|
|
1004
|
-
);
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1007
|
-
// When virtualization is disabled we may render items before initialItemIndex
|
|
1008
|
-
// if initialItemIndex + initialNumToRender < maToRenderPerBatch. Expect cells
|
|
1009
|
-
// 0-3 to be rendered in this example, even though initialScrollIndex is 4.
|
|
1010
|
-
expect(component).toMatchSnapshot();
|
|
1011
|
-
});
|
|
1012
|
-
|
|
1013
|
-
it('renders items before initialScrollIndex on first batch tick when virtualization disabled', () => {
|
|
1014
|
-
const items = generateItems(10);
|
|
1015
|
-
const ITEM_HEIGHT = 10;
|
|
1016
|
-
|
|
1017
|
-
let component;
|
|
1018
|
-
ReactTestRenderer.act(() => {
|
|
1019
|
-
component = ReactTestRenderer.create(
|
|
1020
|
-
<VirtualizedList
|
|
1021
|
-
initialNumToRender={1}
|
|
1022
|
-
initialScrollIndex={5}
|
|
1023
|
-
maxToRenderPerBatch={1}
|
|
1024
|
-
disableVirtualization
|
|
1025
|
-
{...baseItemProps(items)}
|
|
1026
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1027
|
-
/>,
|
|
1028
|
-
);
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
ReactTestRenderer.act(() => {
|
|
1032
|
-
simulateLayout(component, {
|
|
1033
|
-
viewport: {width: 10, height: 50},
|
|
1034
|
-
content: {width: 10, height: 100},
|
|
1035
|
-
});
|
|
1036
|
-
performNextBatch();
|
|
1037
|
-
});
|
|
1038
|
-
|
|
1039
|
-
// When virtualization is disabled, we render "maxToRenderPerBatch" items
|
|
1040
|
-
// sequentially per batch tick. Any items not yet rendered before
|
|
1041
|
-
// initialScrollIndex are currently rendered at this time. Expect the first
|
|
1042
|
-
// tick to render all items before initialScrollIndex, along with
|
|
1043
|
-
// maxToRenderPerBatch after.
|
|
1044
|
-
expect(component).toMatchSnapshot();
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1047
|
-
it('eventually renders all items when virtualization disabled', () => {
|
|
1048
|
-
const items = generateItems(10);
|
|
1049
|
-
const ITEM_HEIGHT = 10;
|
|
1050
|
-
|
|
1051
|
-
let component;
|
|
1052
|
-
ReactTestRenderer.act(() => {
|
|
1053
|
-
component = ReactTestRenderer.create(
|
|
1054
|
-
<VirtualizedList
|
|
1055
|
-
initialNumToRender={5}
|
|
1056
|
-
initialScrollIndex={1}
|
|
1057
|
-
windowSize={1}
|
|
1058
|
-
maxToRenderPerBatch={10}
|
|
1059
|
-
disableVirtualization
|
|
1060
|
-
{...baseItemProps(items)}
|
|
1061
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1062
|
-
/>,
|
|
1063
|
-
);
|
|
1064
|
-
});
|
|
1065
|
-
|
|
1066
|
-
ReactTestRenderer.act(() => {
|
|
1067
|
-
simulateLayout(component, {
|
|
1068
|
-
viewport: {width: 10, height: 50},
|
|
1069
|
-
content: {width: 10, height: 100},
|
|
1070
|
-
});
|
|
1071
|
-
performAllBatches();
|
|
1072
|
-
});
|
|
1073
|
-
|
|
1074
|
-
// After all batch ticks, all items should eventually be rendered when\
|
|
1075
|
-
// virtualization is disabled.
|
|
1076
|
-
expect(component).toMatchSnapshot();
|
|
1077
|
-
});
|
|
1078
|
-
|
|
1079
|
-
it('retains initial render region when an item is appended', () => {
|
|
1080
|
-
const items = generateItems(10);
|
|
1081
|
-
const ITEM_HEIGHT = 10;
|
|
1082
|
-
|
|
1083
|
-
let component;
|
|
1084
|
-
ReactTestRenderer.act(() => {
|
|
1085
|
-
component = ReactTestRenderer.create(
|
|
1086
|
-
<VirtualizedList
|
|
1087
|
-
initialNumToRender={3}
|
|
1088
|
-
{...baseItemProps(items)}
|
|
1089
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1090
|
-
/>,
|
|
1091
|
-
);
|
|
1092
|
-
});
|
|
1093
|
-
|
|
1094
|
-
ReactTestRenderer.act(() => {
|
|
1095
|
-
component.update(
|
|
1096
|
-
<VirtualizedList
|
|
1097
|
-
initialNumToRender={3}
|
|
1098
|
-
{...baseItemProps(items)}
|
|
1099
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1100
|
-
data={generateItems(11)}
|
|
1101
|
-
/>,
|
|
1102
|
-
);
|
|
1103
|
-
});
|
|
1104
|
-
|
|
1105
|
-
// Adding an item to the list before batch render should keep the existing
|
|
1106
|
-
// rendered items rendered. Expect the first 3 items rendered, and a spacer
|
|
1107
|
-
// for 8 items (including the 11th, added item).
|
|
1108
|
-
expect(component).toMatchSnapshot();
|
|
1109
|
-
});
|
|
1110
|
-
|
|
1111
|
-
it('retains batch render region when an item is appended', () => {
|
|
1112
|
-
const items = generateItems(10);
|
|
1113
|
-
const ITEM_HEIGHT = 10;
|
|
1114
|
-
|
|
1115
|
-
let component;
|
|
1116
|
-
ReactTestRenderer.act(() => {
|
|
1117
|
-
component = ReactTestRenderer.create(
|
|
1118
|
-
<VirtualizedList
|
|
1119
|
-
initialNumToRender={1}
|
|
1120
|
-
maxToRenderPerBatch={1}
|
|
1121
|
-
{...baseItemProps(items)}
|
|
1122
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1123
|
-
/>,
|
|
1124
|
-
);
|
|
1125
|
-
});
|
|
1126
|
-
|
|
1127
|
-
ReactTestRenderer.act(() => {
|
|
1128
|
-
simulateLayout(component, {
|
|
1129
|
-
viewport: {width: 10, height: 50},
|
|
1130
|
-
content: {width: 10, height: 100},
|
|
1131
|
-
});
|
|
1132
|
-
performAllBatches();
|
|
1133
|
-
});
|
|
1134
|
-
|
|
1135
|
-
jest.runAllTimers();
|
|
1136
|
-
|
|
1137
|
-
ReactTestRenderer.act(() => {
|
|
1138
|
-
component.update(
|
|
1139
|
-
<VirtualizedList
|
|
1140
|
-
initialNumToRender={1}
|
|
1141
|
-
maxToRenderPerBatch={1}
|
|
1142
|
-
{...baseItemProps(items)}
|
|
1143
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1144
|
-
data={generateItems(11)}
|
|
1145
|
-
/>,
|
|
1146
|
-
);
|
|
1147
|
-
});
|
|
1148
|
-
|
|
1149
|
-
// Adding an item to the list after batch render should keep the existing
|
|
1150
|
-
// rendered items rendered. We batch render 10 items, then add an 11th. Expect
|
|
1151
|
-
// the first ten items to be present, with a spacer for the 11th until the
|
|
1152
|
-
// next batch render.
|
|
1153
|
-
expect(component).toMatchSnapshot();
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
it('constrains batch render region when an item is removed', () => {
|
|
1157
|
-
const items = generateItems(10);
|
|
1158
|
-
const ITEM_HEIGHT = 10;
|
|
1159
|
-
|
|
1160
|
-
let component;
|
|
1161
|
-
ReactTestRenderer.act(() => {
|
|
1162
|
-
component = ReactTestRenderer.create(
|
|
1163
|
-
<VirtualizedList
|
|
1164
|
-
initialNumToRender={1}
|
|
1165
|
-
maxToRenderPerBatch={1}
|
|
1166
|
-
{...baseItemProps(items)}
|
|
1167
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1168
|
-
/>,
|
|
1169
|
-
);
|
|
1170
|
-
});
|
|
1171
|
-
|
|
1172
|
-
ReactTestRenderer.act(() => {
|
|
1173
|
-
simulateLayout(component, {
|
|
1174
|
-
viewport: {width: 10, height: 50},
|
|
1175
|
-
content: {width: 10, height: 100},
|
|
1176
|
-
});
|
|
1177
|
-
performAllBatches();
|
|
1178
|
-
});
|
|
1179
|
-
|
|
1180
|
-
ReactTestRenderer.act(() => {
|
|
1181
|
-
component.update(
|
|
1182
|
-
<VirtualizedList
|
|
1183
|
-
initialNumToRender={1}
|
|
1184
|
-
maxToRenderPerBatch={1}
|
|
1185
|
-
{...baseItemProps(items)}
|
|
1186
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1187
|
-
data={generateItems(5)}
|
|
1188
|
-
/>,
|
|
1189
|
-
);
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
// If the number of items is reduced, we should remove the corresponding
|
|
1193
|
-
// already rendered items. Expect there to be 5 items present. New items in a
|
|
1194
|
-
// previously occupied index may also be immediately rendered.
|
|
1195
|
-
expect(component).toMatchSnapshot();
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
it('renders a zero-height tail spacer on initial render if getItemLayout not defined', () => {
|
|
1199
|
-
const items = generateItems(10);
|
|
1200
|
-
|
|
1201
|
-
const component = ReactTestRenderer.create(
|
|
1202
|
-
<VirtualizedList initialNumToRender={3} {...baseItemProps(items)} />,
|
|
1203
|
-
);
|
|
1204
|
-
|
|
1205
|
-
// Do not add space for out-of-viewport content on initial render when we do
|
|
1206
|
-
// not yet know how large it should be (no getItemLayout and cell onLayout not
|
|
1207
|
-
// yet called). Expect the tail spacer not to occupy space.
|
|
1208
|
-
expect(component).toMatchSnapshot();
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
it('renders zero-height tail spacer on batch render if cells not yet measured and getItemLayout not defined', () => {
|
|
1212
|
-
const items = generateItems(10);
|
|
1213
|
-
|
|
1214
|
-
let component;
|
|
1215
|
-
ReactTestRenderer.act(() => {
|
|
1216
|
-
component = ReactTestRenderer.create(
|
|
1217
|
-
<VirtualizedList
|
|
1218
|
-
initialNumToRender={3}
|
|
1219
|
-
maxToRenderPerBatch={1}
|
|
1220
|
-
windowSize={1}
|
|
1221
|
-
{...baseItemProps(items)}
|
|
1222
|
-
/>,
|
|
1223
|
-
);
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
ReactTestRenderer.act(() => {
|
|
1227
|
-
simulateLayout(component, {
|
|
1228
|
-
viewport: {width: 10, height: 50},
|
|
1229
|
-
content: {width: 10, height: 200},
|
|
1230
|
-
});
|
|
1231
|
-
performNextBatch();
|
|
1232
|
-
});
|
|
1233
|
-
|
|
1234
|
-
// Do not add space for out-of-viewport content unless the cell has previously
|
|
1235
|
-
// been layed out and measurements cached. Expect the tail spacer not to
|
|
1236
|
-
// occupy space.
|
|
1237
|
-
expect(component).toMatchSnapshot();
|
|
1238
|
-
});
|
|
1239
|
-
|
|
1240
|
-
it('renders tail spacer up to last measured index if getItemLayout not defined', () => {
|
|
1241
|
-
const items = generateItems(10);
|
|
1242
|
-
|
|
1243
|
-
let component;
|
|
1244
|
-
ReactTestRenderer.act(() => {
|
|
1245
|
-
component = ReactTestRenderer.create(
|
|
1246
|
-
<VirtualizedList
|
|
1247
|
-
initialNumToRender={3}
|
|
1248
|
-
maxToRenderPerBatch={1}
|
|
1249
|
-
windowSize={1}
|
|
1250
|
-
{...baseItemProps(items)}
|
|
1251
|
-
/>,
|
|
1252
|
-
);
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
ReactTestRenderer.act(() => {
|
|
1256
|
-
const LAST_MEASURED_CELL = 6;
|
|
1257
|
-
for (let i = 0; i <= LAST_MEASURED_CELL; ++i) {
|
|
1258
|
-
simulateCellLayout(component, items, i, {
|
|
1259
|
-
width: 10,
|
|
1260
|
-
height: 10,
|
|
1261
|
-
x: 0,
|
|
1262
|
-
y: 10 * i,
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
simulateLayout(component, {
|
|
1267
|
-
viewport: {width: 10, height: 50},
|
|
1268
|
-
content: {width: 10, height: 30},
|
|
1269
|
-
});
|
|
1270
|
-
performNextBatch();
|
|
1271
|
-
});
|
|
1272
|
-
|
|
1273
|
-
// If cells in the out-of-viewport area have been measured, their space can be
|
|
1274
|
-
// incorporated into the tail spacer, without space for the cells we can not
|
|
1275
|
-
// measure until layout. Expect there to be a tail spacer occupying the space
|
|
1276
|
-
// for measured, but not yet rendered items (up to and including item 6).
|
|
1277
|
-
expect(component).toMatchSnapshot();
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
it('renders tail spacer up to last measured with irregular layout when getItemLayout undefined', () => {
|
|
1281
|
-
const items = generateItems(10);
|
|
1282
|
-
|
|
1283
|
-
let component;
|
|
1284
|
-
ReactTestRenderer.act(() => {
|
|
1285
|
-
component = ReactTestRenderer.create(
|
|
1286
|
-
<VirtualizedList
|
|
1287
|
-
initialNumToRender={3}
|
|
1288
|
-
maxToRenderPerBatch={1}
|
|
1289
|
-
windowSize={1}
|
|
1290
|
-
{...baseItemProps(items)}
|
|
1291
|
-
/>,
|
|
1292
|
-
);
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
ReactTestRenderer.act(() => {
|
|
1296
|
-
const LAST_MEASURED_CELL = 6;
|
|
1297
|
-
|
|
1298
|
-
let currentY = 0;
|
|
1299
|
-
for (let i = 0; i <= LAST_MEASURED_CELL; ++i) {
|
|
1300
|
-
simulateCellLayout(component, items, i, {
|
|
1301
|
-
width: 10,
|
|
1302
|
-
height: i,
|
|
1303
|
-
x: 0,
|
|
1304
|
-
y: currentY + i,
|
|
1305
|
-
});
|
|
1306
|
-
currentY += i;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
simulateLayout(component, {
|
|
1310
|
-
viewport: {width: 10, height: 50},
|
|
1311
|
-
content: {width: 10, height: 30},
|
|
1312
|
-
});
|
|
1313
|
-
performNextBatch();
|
|
1314
|
-
});
|
|
1315
|
-
|
|
1316
|
-
// If cells in the out-of-viewport area have been measured, their space can be
|
|
1317
|
-
// incorporated into the tail spacer, without space for the cells we can not
|
|
1318
|
-
// measure until layout. Expect there to be a tail spacer occupying the space
|
|
1319
|
-
// for measured, but not yet rendered items (up to and including item 6).
|
|
1320
|
-
expect(component).toMatchSnapshot();
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
it('renders full tail spacer if all cells measured', () => {
|
|
1324
|
-
const items = generateItems(10);
|
|
1325
|
-
|
|
1326
|
-
let component;
|
|
1327
|
-
ReactTestRenderer.act(() => {
|
|
1328
|
-
component = ReactTestRenderer.create(
|
|
1329
|
-
<VirtualizedList
|
|
1330
|
-
initialNumToRender={3}
|
|
1331
|
-
maxToRenderPerBatch={1}
|
|
1332
|
-
windowSize={1}
|
|
1333
|
-
{...baseItemProps(items)}
|
|
1334
|
-
/>,
|
|
1335
|
-
);
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
ReactTestRenderer.act(() => {
|
|
1339
|
-
const LAST_MEASURED_CELL = 9;
|
|
1340
|
-
for (let i = 0; i <= LAST_MEASURED_CELL; ++i) {
|
|
1341
|
-
simulateCellLayout(component, items, i, {
|
|
1342
|
-
width: 10,
|
|
1343
|
-
height: 10,
|
|
1344
|
-
x: 0,
|
|
1345
|
-
y: 10 * i,
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
simulateLayout(component, {
|
|
1350
|
-
viewport: {width: 10, height: 50},
|
|
1351
|
-
content: {width: 10, height: 30},
|
|
1352
|
-
});
|
|
1353
|
-
performNextBatch();
|
|
1354
|
-
});
|
|
1355
|
-
|
|
1356
|
-
// The tail-spacer should occupy the space of all non-rendered items if all
|
|
1357
|
-
// items have been measured.
|
|
1358
|
-
expect(component).toMatchSnapshot();
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
it('renders windowSize derived region at top', () => {
|
|
1362
|
-
const items = generateItems(10);
|
|
1363
|
-
const ITEM_HEIGHT = 10;
|
|
1364
|
-
|
|
1365
|
-
let component;
|
|
1366
|
-
ReactTestRenderer.act(() => {
|
|
1367
|
-
component = ReactTestRenderer.create(
|
|
1368
|
-
<VirtualizedList
|
|
1369
|
-
initialNumToRender={1}
|
|
1370
|
-
maxToRenderPerBatch={1}
|
|
1371
|
-
windowSize={3}
|
|
1372
|
-
{...baseItemProps(items)}
|
|
1373
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1374
|
-
/>,
|
|
1375
|
-
);
|
|
1376
|
-
});
|
|
1377
|
-
|
|
1378
|
-
ReactTestRenderer.act(() => {
|
|
1379
|
-
simulateLayout(component, {
|
|
1380
|
-
viewport: {width: 10, height: 20},
|
|
1381
|
-
content: {width: 10, height: 100},
|
|
1382
|
-
});
|
|
1383
|
-
performAllBatches();
|
|
1384
|
-
});
|
|
1385
|
-
|
|
1386
|
-
jest.runAllTimers();
|
|
1387
|
-
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1388
|
-
// above and below the current. A 20 dip viewport at the top of the list means
|
|
1389
|
-
// we should render the top 4 10-dip items (for the current viewport, and
|
|
1390
|
-
// 20dip below).
|
|
1391
|
-
expect(component).toMatchSnapshot();
|
|
1392
|
-
});
|
|
1393
|
-
|
|
1394
|
-
it('renders windowSize derived region in middle', () => {
|
|
1395
|
-
const items = generateItems(10);
|
|
1396
|
-
const ITEM_HEIGHT = 10;
|
|
1397
|
-
|
|
1398
|
-
let component;
|
|
1399
|
-
ReactTestRenderer.act(() => {
|
|
1400
|
-
component = ReactTestRenderer.create(
|
|
1401
|
-
<VirtualizedList
|
|
1402
|
-
initialNumToRender={1}
|
|
1403
|
-
maxToRenderPerBatch={1}
|
|
1404
|
-
windowSize={3}
|
|
1405
|
-
{...baseItemProps(items)}
|
|
1406
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1407
|
-
/>,
|
|
1408
|
-
);
|
|
1409
|
-
});
|
|
1410
|
-
|
|
1411
|
-
ReactTestRenderer.act(() => {
|
|
1412
|
-
simulateLayout(component, {
|
|
1413
|
-
viewport: {width: 10, height: 20},
|
|
1414
|
-
content: {width: 10, height: 100},
|
|
1415
|
-
});
|
|
1416
|
-
performAllBatches();
|
|
1417
|
-
});
|
|
1418
|
-
|
|
1419
|
-
ReactTestRenderer.act(() => {
|
|
1420
|
-
simulateScroll(component, {x: 0, y: 50});
|
|
1421
|
-
performAllBatches();
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
jest.runAllTimers();
|
|
1425
|
-
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1426
|
-
// above and below the current. A 20 dip viewport in the top of the list means
|
|
1427
|
-
// we should render the 6 10-dip items (for the current viewport, 20 dip above
|
|
1428
|
-
// and below), along with retaining the top initialNumToRenderItems. We seem
|
|
1429
|
-
// to actually render 7 in the middle due to rounding at the moment.
|
|
1430
|
-
expect(component).toMatchSnapshot();
|
|
1431
|
-
});
|
|
1432
|
-
|
|
1433
|
-
it('renders windowSize derived region at bottom', () => {
|
|
1434
|
-
const items = generateItems(10);
|
|
1435
|
-
const ITEM_HEIGHT = 10;
|
|
1436
|
-
|
|
1437
|
-
let component;
|
|
1438
|
-
ReactTestRenderer.act(() => {
|
|
1439
|
-
component = ReactTestRenderer.create(
|
|
1440
|
-
<VirtualizedList
|
|
1441
|
-
initialNumToRender={1}
|
|
1442
|
-
maxToRenderPerBatch={1}
|
|
1443
|
-
windowSize={3}
|
|
1444
|
-
{...baseItemProps(items)}
|
|
1445
|
-
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
1446
|
-
/>,
|
|
1447
|
-
);
|
|
1448
|
-
});
|
|
1449
|
-
|
|
1450
|
-
ReactTestRenderer.act(() => {
|
|
1451
|
-
simulateLayout(component, {
|
|
1452
|
-
viewport: {width: 10, height: 20},
|
|
1453
|
-
content: {width: 10, height: 100},
|
|
1454
|
-
});
|
|
1455
|
-
performAllBatches();
|
|
1456
|
-
});
|
|
1457
|
-
ReactTestRenderer.act(() => {
|
|
1458
|
-
simulateScroll(component, {x: 0, y: 80});
|
|
1459
|
-
performAllBatches();
|
|
1460
|
-
});
|
|
1461
|
-
|
|
1462
|
-
jest.runAllTimers();
|
|
1463
|
-
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1464
|
-
// above and below the current. A 20 dip viewport at the bottom of the list
|
|
1465
|
-
// means we should render the bottom 4 10-dip items (for the current viewport,
|
|
1466
|
-
// and 20dip above), along with retaining the top initialNumToRenderItems. We
|
|
1467
|
-
// seem to actually render 4 at the bottom due to rounding at the moment.
|
|
1468
|
-
expect(component).toMatchSnapshot();
|
|
1469
|
-
});
|
|
1470
|
-
|
|
1471
|
-
it('calls _onCellLayout properly', () => {
|
|
1472
|
-
const items = [{key: 'i1'}, {key: 'i2'}, {key: 'i3'}];
|
|
1473
|
-
const mock = jest.fn();
|
|
1474
|
-
const component = ReactTestRenderer.create(
|
|
1475
|
-
<VirtualizedList
|
|
1476
|
-
data={items}
|
|
1477
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
1478
|
-
getItem={(data, index) => data[index]}
|
|
1479
|
-
getItemCount={data => data.length}
|
|
1480
|
-
/>,
|
|
1481
|
-
);
|
|
1482
|
-
const virtualList: VirtualizedList = component.getInstance();
|
|
1483
|
-
virtualList._onCellLayout = mock;
|
|
1484
|
-
component.update(
|
|
1485
|
-
<VirtualizedList
|
|
1486
|
-
data={[...items, {key: 'i4'}]}
|
|
1487
|
-
renderItem={({item}) => <item value={item.key} />}
|
|
1488
|
-
getItem={(data, index) => data[index]}
|
|
1489
|
-
getItemCount={data => data.length}
|
|
1490
|
-
/>,
|
|
1491
|
-
);
|
|
1492
|
-
const cell = virtualList._cellRefs.i4;
|
|
1493
|
-
const event = {
|
|
1494
|
-
nativeEvent: {layout: {x: 0, y: 0, width: 50, height: 50}, zoomScale: 1},
|
|
1495
|
-
};
|
|
1496
|
-
cell._onLayout(event);
|
|
1497
|
-
expect(mock).toHaveBeenCalledWith(event, 'i4', 3);
|
|
1498
|
-
expect(mock).not.toHaveBeenCalledWith(event, 'i3', 2);
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
|
-
function generateItems(count) {
|
|
1502
|
-
return Array(count)
|
|
1503
|
-
.fill()
|
|
1504
|
-
.map((_, i) => ({key: i}));
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
function generateItemsStickyEveryN(count, n) {
|
|
1508
|
-
return Array(count)
|
|
1509
|
-
.fill()
|
|
1510
|
-
.map((_, i) => (i % n === 0 ? {key: i, sticky: true} : {key: i}));
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
function baseItemProps(items) {
|
|
1514
|
-
return {
|
|
1515
|
-
data: items,
|
|
1516
|
-
renderItem: ({item}) =>
|
|
1517
|
-
React.createElement('MockCellItem', {value: item.key, ...item}),
|
|
1518
|
-
getItem: (data, index) => data[index],
|
|
1519
|
-
getItemCount: data => data.length,
|
|
1520
|
-
stickyHeaderIndices: stickyHeaderIndices(items),
|
|
1521
|
-
};
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
function stickyHeaderIndices(items) {
|
|
1525
|
-
return items.filter(item => item.sticky).map(item => item.key);
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
function fixedHeightItemLayoutProps(height) {
|
|
1529
|
-
return {
|
|
1530
|
-
getItemLayout: (_, index) => ({
|
|
1531
|
-
length: height,
|
|
1532
|
-
offset: height * index,
|
|
1533
|
-
index,
|
|
1534
|
-
}),
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
let lastViewportLayout;
|
|
1539
|
-
let lastContentLayout;
|
|
1540
|
-
|
|
1541
|
-
function simulateLayout(component, args) {
|
|
1542
|
-
simulateViewportLayout(component, args.viewport);
|
|
1543
|
-
simulateContentLayout(component, args.content);
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
function simulateViewportLayout(component, dimensions) {
|
|
1547
|
-
lastViewportLayout = dimensions;
|
|
1548
|
-
component
|
|
1549
|
-
.getInstance()
|
|
1550
|
-
._onLayout({nativeEvent: {layout: dimensions}, zoomScale: 1});
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
function simulateContentLayout(component, dimensions) {
|
|
1554
|
-
lastContentLayout = dimensions;
|
|
1555
|
-
component
|
|
1556
|
-
.getInstance()
|
|
1557
|
-
._onContentSizeChange(dimensions.width, dimensions.height);
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function simulateCellLayout(component, items, itemIndex, dimensions) {
|
|
1561
|
-
const instance = component.getInstance();
|
|
1562
|
-
const cellKey = instance._keyExtractor(items[itemIndex], itemIndex);
|
|
1563
|
-
instance._onCellLayout(
|
|
1564
|
-
{nativeEvent: {layout: dimensions, zoomScale: 1}},
|
|
1565
|
-
cellKey,
|
|
1566
|
-
itemIndex,
|
|
1567
|
-
);
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
function simulateScroll(component, position) {
|
|
1571
|
-
component.getInstance()._onScroll({
|
|
1572
|
-
nativeEvent: {
|
|
1573
|
-
contentOffset: position,
|
|
1574
|
-
contentSize: lastContentLayout,
|
|
1575
|
-
layoutMeasurement: lastViewportLayout,
|
|
1576
|
-
zoomScale: 1,
|
|
1577
|
-
},
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
function performAllBatches() {
|
|
1582
|
-
jest.runAllTimers();
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
function performNextBatch() {
|
|
1586
|
-
jest.runOnlyPendingTimers();
|
|
1587
|
-
}
|