@office-iss/react-native-win32 0.68.0-preview.2 → 0.69.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/.flowconfig +3 -3
- package/CHANGELOG.json +386 -14
- package/CHANGELOG.md +159 -9
- package/IntegrationTests/BUCK +4 -1
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -0
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
- package/Libraries/Alert/Alert.win32.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +1 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +55 -9
- package/Libraries/Animated/NativeAnimatedModule.js +1 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
- package/Libraries/Animated/animations/TimingAnimation.js +6 -11
- package/Libraries/Animated/createAnimatedComponent.js +2 -2
- package/Libraries/Animated/nodes/AnimatedColor.js +95 -29
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +19 -22
- package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
- package/Libraries/AppState/AppState.js +1 -1
- package/Libraries/Blob/URL.js +7 -1
- package/Libraries/Components/Button.js +3 -0
- package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +5 -0
- package/Libraries/Components/Pressable/Pressable.js +3 -3
- package/Libraries/Components/Pressable/Pressable.win32.js +3 -3
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +47 -38
- package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +15 -7
- package/Libraries/Components/ScrollView/ScrollView.js +1 -1
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -3
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
- package/Libraries/Components/Slider/Slider.js +0 -2
- package/Libraries/Components/Slider/SliderNativeComponent.js +0 -1
- package/Libraries/Components/StatusBar/StatusBar.js +6 -1
- package/Libraries/Components/Switch/Switch.js +13 -2
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +114 -109
- package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +17 -9
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +13 -5
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
- package/Libraries/Components/TextInput/TextInput.js +1 -8
- package/Libraries/Components/TextInput/TextInputState.js +10 -2
- package/Libraries/Components/TextInput/TextInputState.win32.js +10 -2
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -0
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -0
- package/Libraries/Components/Touchable/TouchableOpacity.js +7 -1
- package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +3 -1
- package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
- package/Libraries/Components/View/View.win32.js +33 -1
- package/Libraries/Components/View/ViewNativeComponent.js +68 -8
- package/Libraries/Components/View/ViewPropTypes.js +36 -4
- package/Libraries/Components/View/ViewPropTypes.win32.js +36 -4
- package/Libraries/Components/View/ViewWin32.Props.d.ts +1 -1
- package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
- package/Libraries/Core/Devtools/parseHermesStack.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +1 -1
- package/Libraries/Core/RawEventEmitter.js +38 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/polyfillPromise.js +32 -0
- package/Libraries/Core/setUpReactDevTools.js +3 -2
- package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -3
- package/Libraries/Events/CustomEvent.js +32 -0
- package/Libraries/Events/EventPolyfill.js +239 -0
- package/Libraries/Image/Image.android.js +0 -6
- package/Libraries/Image/Image.ios.js +0 -6
- package/Libraries/Image/Image.win32.js +2 -8
- package/Libraries/Image/ImageViewNativeComponent.js +18 -3
- package/Libraries/Image/TextInlineImageNativeComponent.js +23 -15
- package/Libraries/Image/resolveAssetSource.win32.js +1 -1
- package/Libraries/Inspector/Inspector.js +2 -4
- package/Libraries/Inspector/Inspector.win32.js +7 -9
- package/Libraries/Interaction/BridgeSpyStallHandler.js +4 -3
- package/Libraries/Interaction/InteractionManager.js +1 -12
- package/Libraries/Interaction/TaskQueue.js +5 -4
- package/Libraries/LayoutAnimation/LayoutAnimation.js +13 -0
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.js +27 -6
- package/Libraries/Lists/VirtualizedList.js +71 -55
- package/Libraries/Lists/VirtualizedListContext.js +7 -3
- package/Libraries/Lists/VirtualizedSectionList.js +2 -2
- package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
- package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
- package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
- package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
- package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +92 -43
- package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +16 -14
- package/Libraries/LogBox/Data/LogBoxData.js +2 -2
- package/Libraries/LogBox/Data/LogBoxLog.js +1 -1
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +2 -21
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +2 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +295 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +333 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +334 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +0 -2
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +24 -0
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +7 -42
- package/Libraries/NativeComponent/ViewConfig.js +4 -4
- package/Libraries/NativeComponent/ViewConfigIgnore.js +54 -0
- package/Libraries/Network/FormData.js +7 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Pressability/Pressability.js +115 -46
- package/Libraries/Pressability/Pressability.win32.js +174 -69
- package/Libraries/Pressability/PressabilityDebug.js +5 -9
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/{DummyUIManager.js → BridgelessUIManager.js} +62 -40
- package/Libraries/ReactNative/PaperUIManager.win32.js +5 -5
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +39 -0
- package/Libraries/ReactNative/UIManager.js +2 -3
- package/Libraries/ReactNative/renderApplication.js +4 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +8 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +5908 -4906
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +2100 -1918
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2567 -2352
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5610 -4844
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1710 -1556
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1830 -1639
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
- package/Libraries/StyleSheet/EdgeInsetsPropType.js +4 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +59 -66
- package/Libraries/StyleSheet/normalizeColor.js +1 -1
- package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +15 -0
- package/Libraries/StyleSheet/private/_TransformStyle.js +53 -0
- package/Libraries/Text/Text.js +13 -7
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextNativeComponent.win32.js +2 -0
- package/Libraries/Text/TextProps.js +10 -0
- package/Libraries/Types/CoreEventTypes.js +13 -1
- package/Libraries/Types/CoreEventTypes.win32.js +26 -1
- package/Libraries/Utilities/Appearance.js +0 -8
- package/Libraries/Utilities/HMRClient.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -0
- package/Libraries/Utilities/codegenNativeComponent.js +17 -6
- package/Libraries/Utilities/stringifySafe.js +4 -1
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/vendor/emitter/_EmitterSubscription.js +1 -1
- package/Libraries/vendor/emitter/_EventEmitter.js +1 -1
- package/Libraries/vendor/emitter/_EventSubscription.js +1 -1
- package/index.js +30 -25
- package/index.win32.js +30 -25
- package/jest/preprocessor.js +24 -107
- package/jest/preprocessor_DO_NOT_USE.js +122 -0
- package/metro.config.js +3 -47
- package/overrides.json +39 -46
- package/package.json +28 -26
- package/rntypes/index.d.ts +19 -7
- package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +1 -1
- package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +3 -1
- package/src/Libraries/Components/View/ViewWin32.Props.ts +1 -0
- package/src/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +427 -0
- package/src/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +391 -0
- package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap +3 -0
- package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +4565 -0
- package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +1153 -0
- package/src/rntypes/index.d.ts +19 -7
- package/typings-index.js +5 -1
- package/typings-index.js.map +1 -1
- package/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +0 -44
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +0 -45
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +0 -123
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.js +0 -45
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +0 -360
- package/Libraries/Components/View/ReactNativeViewViewConfig.win32.js +0 -401
- package/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +0 -83
- package/Libraries/ReactNative/UIManagerInjection.js +0 -15
- package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +0 -24527
- package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +0 -8309
- package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +0 -8961
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +0 -24948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +0 -8400
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +0 -9049
- package/flow/Promise.js +0 -47
|
@@ -137,8 +137,7 @@ class VirtualizedSectionList<
|
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) {
|
|
140
|
-
|
|
141
|
-
const frame = this._listRef._getFrameMetricsApprox(
|
|
140
|
+
const frame = this._listRef.__getFrameMetricsApprox(
|
|
142
141
|
index - params.itemIndex,
|
|
143
142
|
);
|
|
144
143
|
viewOffset += frame.length;
|
|
@@ -339,6 +338,7 @@ class VirtualizedSectionList<
|
|
|
339
338
|
|
|
340
339
|
_renderItem =
|
|
341
340
|
(listItemCount: number) =>
|
|
341
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
342
342
|
({item, index}: {item: Item, index: number, ...}) => {
|
|
343
343
|
const info = this._subExtractor(index);
|
|
344
344
|
if (!info) {
|
|
@@ -31,7 +31,7 @@ function computeResult({helper, props, state, scroll}): number {
|
|
|
31
31
|
return helper.computeBlankness(
|
|
32
32
|
{
|
|
33
33
|
data: dataGlobal,
|
|
34
|
-
getItemCount:
|
|
34
|
+
getItemCount: data2 => data2.length,
|
|
35
35
|
initialNumToRender: 10,
|
|
36
36
|
...(props || {}),
|
|
37
37
|
},
|
|
@@ -98,7 +98,7 @@ describe('computeBlankness', function () {
|
|
|
98
98
|
|
|
99
99
|
it('can handle multiple listeners and unsubscribe', function () {
|
|
100
100
|
const listeners = [jest.fn(), jest.fn(), jest.fn()];
|
|
101
|
-
const subscriptions = listeners.map(
|
|
101
|
+
const subscriptions = listeners.map(listener =>
|
|
102
102
|
FillRateHelper.addListener(listener),
|
|
103
103
|
);
|
|
104
104
|
subscriptions[1].remove();
|
|
@@ -102,13 +102,13 @@ describe('FlatList', () => {
|
|
|
102
102
|
ReactTestRenderer.create(
|
|
103
103
|
<FlatList
|
|
104
104
|
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
105
|
-
renderItem={
|
|
105
|
+
renderItem={outerInfo => (
|
|
106
106
|
<FlatList
|
|
107
107
|
data={[
|
|
108
108
|
{key: outerInfo.item.key + ':inner0'},
|
|
109
109
|
{key: outerInfo.item.key + ':inner1'},
|
|
110
110
|
]}
|
|
111
|
-
renderItem={
|
|
111
|
+
renderItem={innerInfo => {
|
|
112
112
|
return <item title={innerInfo.item.key} />;
|
|
113
113
|
}}
|
|
114
114
|
ref={listRef}
|
|
@@ -39,21 +39,21 @@ describe('SectionList', () => {
|
|
|
39
39
|
const component = ReactTestRenderer.create(
|
|
40
40
|
<SectionList
|
|
41
41
|
initialNumToRender={Infinity}
|
|
42
|
-
ItemSeparatorComponent={
|
|
42
|
+
ItemSeparatorComponent={props => (
|
|
43
43
|
<defaultItemSeparator v={propStr(props)} />
|
|
44
44
|
)}
|
|
45
|
-
ListEmptyComponent={
|
|
46
|
-
ListFooterComponent={
|
|
47
|
-
ListHeaderComponent={
|
|
48
|
-
SectionSeparatorComponent={
|
|
45
|
+
ListEmptyComponent={props => <empty v={propStr(props)} />}
|
|
46
|
+
ListFooterComponent={props => <footer v={propStr(props)} />}
|
|
47
|
+
ListHeaderComponent={props => <header v={propStr(props)} />}
|
|
48
|
+
SectionSeparatorComponent={props => (
|
|
49
49
|
<sectionSeparator v={propStr(props)} />
|
|
50
50
|
)}
|
|
51
51
|
sections={[
|
|
52
52
|
{
|
|
53
|
-
renderItem:
|
|
53
|
+
renderItem: props => <itemForSection1 v={propStr(props)} />,
|
|
54
54
|
key: 's1',
|
|
55
55
|
keyExtractor: (item, index) => item.id,
|
|
56
|
-
ItemSeparatorComponent:
|
|
56
|
+
ItemSeparatorComponent: props => (
|
|
57
57
|
<itemSeparatorForSection1 v={propStr(props)} />
|
|
58
58
|
),
|
|
59
59
|
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
|
@@ -69,9 +69,9 @@ describe('SectionList', () => {
|
|
|
69
69
|
]}
|
|
70
70
|
refreshing={false}
|
|
71
71
|
onRefresh={jest.fn()}
|
|
72
|
-
renderItem={
|
|
73
|
-
renderSectionHeader={
|
|
74
|
-
renderSectionFooter={
|
|
72
|
+
renderItem={props => <defaultItem v={propStr(props)} />}
|
|
73
|
+
renderSectionHeader={props => <sectionHeader v={propStr(props)} />}
|
|
74
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
75
75
|
/>,
|
|
76
76
|
);
|
|
77
77
|
expect(component).toMatchSnapshot();
|
|
@@ -81,8 +81,8 @@ describe('SectionList', () => {
|
|
|
81
81
|
<SectionList
|
|
82
82
|
sections={[{key: 's1', data: []}]}
|
|
83
83
|
renderItem={({item}) => <item v={item.key} />}
|
|
84
|
-
renderSectionHeader={
|
|
85
|
-
renderSectionFooter={
|
|
84
|
+
renderSectionHeader={props => <sectionHeader v={propStr(props)} />}
|
|
85
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
86
86
|
/>,
|
|
87
87
|
);
|
|
88
88
|
expect(component).toMatchSnapshot();
|
|
@@ -92,7 +92,7 @@ describe('SectionList', () => {
|
|
|
92
92
|
<SectionList
|
|
93
93
|
sections={[{key: 's1', data: []}]}
|
|
94
94
|
renderItem={({item}) => <item v={item.key} />}
|
|
95
|
-
renderSectionFooter={
|
|
95
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
96
96
|
/>,
|
|
97
97
|
);
|
|
98
98
|
expect(component).toMatchSnapshot();
|
|
@@ -101,7 +101,7 @@ describe('SectionList', () => {
|
|
|
101
101
|
|
|
102
102
|
function propStr(props) {
|
|
103
103
|
return Object.keys(props)
|
|
104
|
-
.map(
|
|
104
|
+
.map(k => {
|
|
105
105
|
const propObj = props[k] || {};
|
|
106
106
|
return `${k}:${propObj.key || propObj.id || props[k]}`;
|
|
107
107
|
})
|
package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js}
RENAMED
|
@@ -62,7 +62,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
62
62
|
{offset: 950, length: 150},
|
|
63
63
|
];
|
|
64
64
|
expect(
|
|
65
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
65
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
|
66
66
|
).toEqual([1, 1, 3]);
|
|
67
67
|
});
|
|
68
68
|
it('handles out of bounds', function () {
|
|
@@ -73,7 +73,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
73
73
|
{offset: 250, length: 100},
|
|
74
74
|
];
|
|
75
75
|
expect(
|
|
76
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
76
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
|
77
77
|
).toEqual([1]);
|
|
78
78
|
});
|
|
79
79
|
it('errors on non-increasing offsets', function () {
|
|
@@ -84,7 +84,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
84
84
|
{offset: 250, length: 100},
|
|
85
85
|
];
|
|
86
86
|
expect(() => {
|
|
87
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
87
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]);
|
|
88
88
|
}).toThrowErrorMatchingSnapshot();
|
|
89
89
|
});
|
|
90
90
|
});
|
package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js}
RENAMED
|
@@ -22,7 +22,7 @@ describe('VirtualizedList', () => {
|
|
|
22
22
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
23
23
|
renderItem={({item}) => <item value={item.key} />}
|
|
24
24
|
getItem={(data, index) => data[index]}
|
|
25
|
-
getItemCount={
|
|
25
|
+
getItemCount={data => data.length}
|
|
26
26
|
/>,
|
|
27
27
|
);
|
|
28
28
|
expect(component).toMatchSnapshot();
|
|
@@ -37,7 +37,7 @@ describe('VirtualizedList', () => {
|
|
|
37
37
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
38
38
|
ListItemComponent={ListItemComponent}
|
|
39
39
|
getItem={(data, index) => data[index]}
|
|
40
|
-
getItemCount={
|
|
40
|
+
getItemCount={data => data.length}
|
|
41
41
|
/>,
|
|
42
42
|
);
|
|
43
43
|
expect(component).toMatchSnapshot();
|
|
@@ -56,7 +56,7 @@ describe('VirtualizedList', () => {
|
|
|
56
56
|
<item value={item.key} testID={`${item.key}-renderItem`} />
|
|
57
57
|
)}
|
|
58
58
|
getItem={(data, index) => data[index]}
|
|
59
|
-
getItemCount={
|
|
59
|
+
getItemCount={data => data.length}
|
|
60
60
|
/>,
|
|
61
61
|
);
|
|
62
62
|
|
|
@@ -70,7 +70,7 @@ describe('VirtualizedList', () => {
|
|
|
70
70
|
it('throws if no renderItem or ListItemComponent', () => {
|
|
71
71
|
// Silence the React error boundary warning; we expect an uncaught error.
|
|
72
72
|
const consoleError = console.error;
|
|
73
|
-
jest.spyOn(console, 'error').mockImplementation(
|
|
73
|
+
jest.spyOn(console, 'error').mockImplementation(message => {
|
|
74
74
|
if (message.startsWith('The above error occurred in the ')) {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
@@ -82,7 +82,7 @@ describe('VirtualizedList', () => {
|
|
|
82
82
|
<VirtualizedList
|
|
83
83
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
84
84
|
getItem={(data, index) => data[index]}
|
|
85
|
-
getItemCount={
|
|
85
|
+
getItemCount={data => data.length}
|
|
86
86
|
/>,
|
|
87
87
|
);
|
|
88
88
|
expect(componentFactory).toThrow(
|
|
@@ -98,7 +98,7 @@ describe('VirtualizedList', () => {
|
|
|
98
98
|
data={[]}
|
|
99
99
|
renderItem={({item}) => <item value={item.key} />}
|
|
100
100
|
getItem={(data, index) => data[index]}
|
|
101
|
-
getItemCount={
|
|
101
|
+
getItemCount={data => data.length}
|
|
102
102
|
/>,
|
|
103
103
|
);
|
|
104
104
|
expect(component).toMatchSnapshot();
|
|
@@ -110,7 +110,7 @@ describe('VirtualizedList', () => {
|
|
|
110
110
|
data={[]}
|
|
111
111
|
renderItem={({item}) => <item value={item.key} />}
|
|
112
112
|
getItem={(data, index) => data[index]}
|
|
113
|
-
getItemCount={
|
|
113
|
+
getItemCount={data => data.length}
|
|
114
114
|
/>,
|
|
115
115
|
);
|
|
116
116
|
|
|
@@ -132,7 +132,7 @@ describe('VirtualizedList', () => {
|
|
|
132
132
|
data={undefined}
|
|
133
133
|
renderItem={({item}) => <item value={item.key} />}
|
|
134
134
|
getItem={(data, index) => data[index]}
|
|
135
|
-
getItemCount={
|
|
135
|
+
getItemCount={data => 0}
|
|
136
136
|
/>,
|
|
137
137
|
);
|
|
138
138
|
expect(component).toMatchSnapshot();
|
|
@@ -146,7 +146,7 @@ describe('VirtualizedList', () => {
|
|
|
146
146
|
ListFooterComponent={() => <footer />}
|
|
147
147
|
ListHeaderComponent={() => <header />}
|
|
148
148
|
getItem={(data, index) => data[index]}
|
|
149
|
-
getItemCount={
|
|
149
|
+
getItemCount={data => data.length}
|
|
150
150
|
renderItem={({item}) => <item value={item.key} />}
|
|
151
151
|
/>,
|
|
152
152
|
);
|
|
@@ -159,7 +159,7 @@ describe('VirtualizedList', () => {
|
|
|
159
159
|
data={[{key: 'hello'}]}
|
|
160
160
|
ListEmptyComponent={() => <empty />}
|
|
161
161
|
getItem={(data, index) => data[index]}
|
|
162
|
-
getItemCount={
|
|
162
|
+
getItemCount={data => data.length}
|
|
163
163
|
renderItem={({item}) => <item value={item.key} />}
|
|
164
164
|
/>,
|
|
165
165
|
);
|
|
@@ -175,7 +175,7 @@ describe('VirtualizedList', () => {
|
|
|
175
175
|
ListHeaderComponent={() => <header />}
|
|
176
176
|
data={new Array(5).fill().map((_, ii) => ({id: String(ii)}))}
|
|
177
177
|
getItem={(data, index) => data[index]}
|
|
178
|
-
getItemCount={
|
|
178
|
+
getItemCount={data => data.length}
|
|
179
179
|
getItemLayout={({index}) => ({length: 50, offset: index * 50})}
|
|
180
180
|
inverted={true}
|
|
181
181
|
keyExtractor={(item, index) => item.id}
|
|
@@ -203,14 +203,14 @@ describe('VirtualizedList', () => {
|
|
|
203
203
|
const infos = [];
|
|
204
204
|
const component = ReactTestRenderer.create(
|
|
205
205
|
<VirtualizedList
|
|
206
|
-
ItemSeparatorComponent={
|
|
206
|
+
ItemSeparatorComponent={props => <separator {...props} />}
|
|
207
207
|
data={[{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]}
|
|
208
|
-
renderItem={
|
|
208
|
+
renderItem={info => {
|
|
209
209
|
infos.push(info);
|
|
210
210
|
return <item title={info.item.key} />;
|
|
211
211
|
}}
|
|
212
212
|
getItem={(data, index) => data[index]}
|
|
213
|
-
getItemCount={
|
|
213
|
+
getItemCount={data => data.length}
|
|
214
214
|
/>,
|
|
215
215
|
);
|
|
216
216
|
expect(component).toMatchSnapshot();
|
|
@@ -225,22 +225,22 @@ describe('VirtualizedList', () => {
|
|
|
225
225
|
const component = ReactTestRenderer.create(
|
|
226
226
|
<VirtualizedList
|
|
227
227
|
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
228
|
-
renderItem={
|
|
228
|
+
renderItem={outerInfo => (
|
|
229
229
|
<VirtualizedList
|
|
230
230
|
data={[
|
|
231
231
|
{key: outerInfo.item.key + ':inner0'},
|
|
232
232
|
{key: outerInfo.item.key + ':inner1'},
|
|
233
233
|
]}
|
|
234
234
|
horizontal={outerInfo.item.key === 'outer1'}
|
|
235
|
-
renderItem={
|
|
235
|
+
renderItem={innerInfo => {
|
|
236
236
|
return <item title={innerInfo.item.key} />;
|
|
237
237
|
}}
|
|
238
238
|
getItem={(data, index) => data[index]}
|
|
239
|
-
getItemCount={
|
|
239
|
+
getItemCount={data => data.length}
|
|
240
240
|
/>
|
|
241
241
|
)}
|
|
242
242
|
getItem={(data, index) => data[index]}
|
|
243
|
-
getItemCount={
|
|
243
|
+
getItemCount={data => data.length}
|
|
244
244
|
/>,
|
|
245
245
|
);
|
|
246
246
|
expect(component).toMatchSnapshot();
|
|
@@ -261,7 +261,7 @@ describe('VirtualizedList', () => {
|
|
|
261
261
|
data,
|
|
262
262
|
renderItem: ({item}) => <item value={item.key} />,
|
|
263
263
|
getItem: (items, index) => items[index],
|
|
264
|
-
getItemCount:
|
|
264
|
+
getItemCount: items => items.length,
|
|
265
265
|
getItemLayout: (items, index) => ({
|
|
266
266
|
length: ITEM_HEIGHT,
|
|
267
267
|
offset: ITEM_HEIGHT * index,
|
|
@@ -313,7 +313,7 @@ describe('VirtualizedList', () => {
|
|
|
313
313
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
314
314
|
renderItem={({item}) => <item value={item.key} />}
|
|
315
315
|
getItem={(data, index) => data[index]}
|
|
316
|
-
getItemCount={
|
|
316
|
+
getItemCount={data => data.length}
|
|
317
317
|
ref={listRef}
|
|
318
318
|
/>,
|
|
319
319
|
);
|
|
@@ -331,22 +331,22 @@ describe('VirtualizedList', () => {
|
|
|
331
331
|
ReactTestRenderer.create(
|
|
332
332
|
<VirtualizedList
|
|
333
333
|
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
334
|
-
renderItem={
|
|
334
|
+
renderItem={outerInfo => (
|
|
335
335
|
<VirtualizedList
|
|
336
336
|
data={[
|
|
337
337
|
{key: outerInfo.item.key + ':inner0'},
|
|
338
338
|
{key: outerInfo.item.key + ':inner1'},
|
|
339
339
|
]}
|
|
340
|
-
renderItem={
|
|
340
|
+
renderItem={innerInfo => {
|
|
341
341
|
return <item title={innerInfo.item.key} />;
|
|
342
342
|
}}
|
|
343
343
|
getItem={(data, index) => data[index]}
|
|
344
|
-
getItemCount={
|
|
344
|
+
getItemCount={data => data.length}
|
|
345
345
|
ref={listRef}
|
|
346
346
|
/>
|
|
347
347
|
)}
|
|
348
348
|
getItem={(data, index) => data[index]}
|
|
349
|
-
getItemCount={
|
|
349
|
+
getItemCount={data => data.length}
|
|
350
350
|
/>,
|
|
351
351
|
);
|
|
352
352
|
const scrollRef = listRef.current.getScrollRef();
|
|
@@ -362,7 +362,7 @@ describe('VirtualizedList', () => {
|
|
|
362
362
|
const layout = {width: 300, height: 600};
|
|
363
363
|
let data = Array(20)
|
|
364
364
|
.fill()
|
|
365
|
-
.map((_,
|
|
365
|
+
.map((_, index) => ({key: `key-${index}`}));
|
|
366
366
|
const onEndReached = jest.fn();
|
|
367
367
|
const props = {
|
|
368
368
|
data,
|
|
@@ -371,7 +371,7 @@ describe('VirtualizedList', () => {
|
|
|
371
371
|
windowSize: 21,
|
|
372
372
|
renderItem: ({item}) => <item value={item.key} />,
|
|
373
373
|
getItem: (items, index) => items[index],
|
|
374
|
-
getItemCount:
|
|
374
|
+
getItemCount: items => items.length,
|
|
375
375
|
getItemLayout: (items, index) => ({
|
|
376
376
|
length: ITEM_HEIGHT,
|
|
377
377
|
offset: ITEM_HEIGHT * index,
|
|
@@ -423,7 +423,7 @@ describe('VirtualizedList', () => {
|
|
|
423
423
|
const commonProps = {
|
|
424
424
|
data: [{key: 'cell0'}],
|
|
425
425
|
getItem: (data, index) => data[index],
|
|
426
|
-
getItemCount:
|
|
426
|
+
getItemCount: data => data.length,
|
|
427
427
|
renderItem: ({item}) => <item value={item.key} />,
|
|
428
428
|
};
|
|
429
429
|
try {
|
|
@@ -485,7 +485,7 @@ describe('VirtualizedList', () => {
|
|
|
485
485
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
486
486
|
renderItem={({item}) => <item value={item.key} />}
|
|
487
487
|
getItem={(data, index) => data[index]}
|
|
488
|
-
getItemCount={
|
|
488
|
+
getItemCount={data => data.length}
|
|
489
489
|
/>,
|
|
490
490
|
);
|
|
491
491
|
const instance = component.getInstance();
|
|
@@ -501,7 +501,7 @@ describe('VirtualizedList', () => {
|
|
|
501
501
|
data={[]}
|
|
502
502
|
renderItem={({item}) => <item value={item.key} />}
|
|
503
503
|
getItem={(data, index) => data[index]}
|
|
504
|
-
getItemCount={
|
|
504
|
+
getItemCount={data => data.length}
|
|
505
505
|
/>,
|
|
506
506
|
);
|
|
507
507
|
const instance = component.getInstance();
|
|
@@ -517,7 +517,7 @@ describe('VirtualizedList', () => {
|
|
|
517
517
|
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
|
|
518
518
|
renderItem={({item}) => <item value={item.key} />}
|
|
519
519
|
getItem={(data, index) => data[index]}
|
|
520
|
-
getItemCount={
|
|
520
|
+
getItemCount={data => data.length}
|
|
521
521
|
/>,
|
|
522
522
|
);
|
|
523
523
|
const instance = component.getInstance();
|
|
@@ -862,7 +862,7 @@ it('does not adjust render area until content area layed out', () => {
|
|
|
862
862
|
expect(component).toMatchSnapshot();
|
|
863
863
|
});
|
|
864
864
|
|
|
865
|
-
it('
|
|
865
|
+
it('adjusts render area with non-zero initialScrollIndex', () => {
|
|
866
866
|
const items = generateItems(20);
|
|
867
867
|
const ITEM_HEIGHT = 10;
|
|
868
868
|
|
|
@@ -885,18 +885,17 @@ it('does not adjust render area with non-zero initialScrollIndex until scrolled'
|
|
|
885
885
|
viewport: {width: 10, height: 50},
|
|
886
886
|
content: {width: 10, height: 200},
|
|
887
887
|
});
|
|
888
|
+
|
|
888
889
|
performAllBatches();
|
|
889
890
|
});
|
|
890
891
|
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
// initial items (starting at initialScrollIndex) to be rendered after
|
|
894
|
-
// processing all batch work, even though the windowSize allows for more.
|
|
892
|
+
// We should expand the render area after receiving a message indcating we
|
|
893
|
+
// arrived at initialScrollIndex.
|
|
895
894
|
expect(component).toMatchSnapshot();
|
|
896
895
|
});
|
|
897
896
|
|
|
898
|
-
it('
|
|
899
|
-
const items = generateItems(
|
|
897
|
+
it('renders new items when data is updated with non-zero initialScrollIndex', () => {
|
|
898
|
+
const items = generateItems(2);
|
|
900
899
|
const ITEM_HEIGHT = 10;
|
|
901
900
|
|
|
902
901
|
let component;
|
|
@@ -918,13 +917,29 @@ it('adjusts render area with non-zero initialScrollIndex after scrolled', () =>
|
|
|
918
917
|
viewport: {width: 10, height: 50},
|
|
919
918
|
content: {width: 10, height: 200},
|
|
920
919
|
});
|
|
920
|
+
performAllBatches();
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
const newItems = generateItems(4);
|
|
924
|
+
|
|
925
|
+
ReactTestRenderer.act(() => {
|
|
926
|
+
component.update(
|
|
927
|
+
<VirtualizedList
|
|
928
|
+
initialNumToRender={5}
|
|
929
|
+
initialScrollIndex={1}
|
|
930
|
+
windowSize={10}
|
|
931
|
+
maxToRenderPerBatch={10}
|
|
932
|
+
{...baseItemProps(newItems)}
|
|
933
|
+
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
|
|
934
|
+
/>,
|
|
935
|
+
);
|
|
936
|
+
});
|
|
921
937
|
|
|
922
|
-
|
|
938
|
+
ReactTestRenderer.act(() => {
|
|
923
939
|
performAllBatches();
|
|
924
940
|
});
|
|
925
941
|
|
|
926
|
-
// We
|
|
927
|
-
// arrived at initialScrollIndex.
|
|
942
|
+
// We expect all the items to be rendered
|
|
928
943
|
expect(component).toMatchSnapshot();
|
|
929
944
|
});
|
|
930
945
|
|
|
@@ -1116,6 +1131,8 @@ it('retains batch render region when an item is appended', () => {
|
|
|
1116
1131
|
performAllBatches();
|
|
1117
1132
|
});
|
|
1118
1133
|
|
|
1134
|
+
jest.runAllTimers();
|
|
1135
|
+
|
|
1119
1136
|
ReactTestRenderer.act(() => {
|
|
1120
1137
|
component.update(
|
|
1121
1138
|
<VirtualizedList
|
|
@@ -1365,6 +1382,7 @@ it('renders windowSize derived region at top', () => {
|
|
|
1365
1382
|
performAllBatches();
|
|
1366
1383
|
});
|
|
1367
1384
|
|
|
1385
|
+
jest.runAllTimers();
|
|
1368
1386
|
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1369
1387
|
// above and below the current. A 20 dip viewport at the top of the list means
|
|
1370
1388
|
// we should render the top 4 10-dip items (for the current viewport, and
|
|
@@ -1402,6 +1420,7 @@ it('renders windowSize derived region in middle', () => {
|
|
|
1402
1420
|
performAllBatches();
|
|
1403
1421
|
});
|
|
1404
1422
|
|
|
1423
|
+
jest.runAllTimers();
|
|
1405
1424
|
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1406
1425
|
// above and below the current. A 20 dip viewport in the top of the list means
|
|
1407
1426
|
// we should render the 6 10-dip items (for the current viewport, 20 dip above
|
|
@@ -1434,12 +1453,12 @@ it('renders windowSize derived region at bottom', () => {
|
|
|
1434
1453
|
});
|
|
1435
1454
|
performAllBatches();
|
|
1436
1455
|
});
|
|
1437
|
-
|
|
1438
1456
|
ReactTestRenderer.act(() => {
|
|
1439
1457
|
simulateScroll(component, {x: 0, y: 80});
|
|
1440
1458
|
performAllBatches();
|
|
1441
1459
|
});
|
|
1442
1460
|
|
|
1461
|
+
jest.runAllTimers();
|
|
1443
1462
|
// A windowSize of 3 means that we should render a viewport's worth of content
|
|
1444
1463
|
// above and below the current. A 20 dip viewport at the bottom of the list
|
|
1445
1464
|
// means we should render the bottom 4 10-dip items (for the current viewport,
|
|
@@ -1448,6 +1467,36 @@ it('renders windowSize derived region at bottom', () => {
|
|
|
1448
1467
|
expect(component).toMatchSnapshot();
|
|
1449
1468
|
});
|
|
1450
1469
|
|
|
1470
|
+
it('calls _onCellLayout properly', () => {
|
|
1471
|
+
const items = [{key: 'i1'}, {key: 'i2'}, {key: 'i3'}];
|
|
1472
|
+
const mock = jest.fn();
|
|
1473
|
+
const component = ReactTestRenderer.create(
|
|
1474
|
+
<VirtualizedList
|
|
1475
|
+
data={items}
|
|
1476
|
+
renderItem={({item}) => <item value={item.key} />}
|
|
1477
|
+
getItem={(data, index) => data[index]}
|
|
1478
|
+
getItemCount={data => data.length}
|
|
1479
|
+
/>,
|
|
1480
|
+
);
|
|
1481
|
+
const virtualList: VirtualizedList = component.getInstance();
|
|
1482
|
+
virtualList._onCellLayout = mock;
|
|
1483
|
+
component.update(
|
|
1484
|
+
<VirtualizedList
|
|
1485
|
+
data={[...items, {key: 'i4'}]}
|
|
1486
|
+
renderItem={({item}) => <item value={item.key} />}
|
|
1487
|
+
getItem={(data, index) => data[index]}
|
|
1488
|
+
getItemCount={data => data.length}
|
|
1489
|
+
/>,
|
|
1490
|
+
);
|
|
1491
|
+
const cell = virtualList._cellRefs.i4;
|
|
1492
|
+
const event = {
|
|
1493
|
+
nativeEvent: {layout: {x: 0, y: 0, width: 50, height: 50}},
|
|
1494
|
+
};
|
|
1495
|
+
cell._onLayout(event);
|
|
1496
|
+
expect(mock).toHaveBeenCalledWith(event, 'i4', 3);
|
|
1497
|
+
expect(mock).not.toHaveBeenCalledWith(event, 'i3', 2);
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1451
1500
|
function generateItems(count) {
|
|
1452
1501
|
return Array(count)
|
|
1453
1502
|
.fill()
|
|
@@ -1466,13 +1515,13 @@ function baseItemProps(items) {
|
|
|
1466
1515
|
renderItem: ({item}) =>
|
|
1467
1516
|
React.createElement('MockCellItem', {value: item.key, ...item}),
|
|
1468
1517
|
getItem: (data, index) => data[index],
|
|
1469
|
-
getItemCount:
|
|
1518
|
+
getItemCount: data => data.length,
|
|
1470
1519
|
stickyHeaderIndices: stickyHeaderIndices(items),
|
|
1471
1520
|
};
|
|
1472
1521
|
}
|
|
1473
1522
|
|
|
1474
1523
|
function stickyHeaderIndices(items) {
|
|
1475
|
-
return items.filter(
|
|
1524
|
+
return items.filter(item => item.sticky).map(item => item.key);
|
|
1476
1525
|
}
|
|
1477
1526
|
|
|
1478
1527
|
function fixedHeightItemLayoutProps(height) {
|
|
@@ -25,7 +25,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
25
25
|
]}
|
|
26
26
|
renderItem={({item}) => <item value={item.key} />}
|
|
27
27
|
getItem={(data, key) => data[key]}
|
|
28
|
-
getItemCount={
|
|
28
|
+
getItemCount={data => data.length}
|
|
29
29
|
/>,
|
|
30
30
|
);
|
|
31
31
|
expect(component).toMatchSnapshot();
|
|
@@ -37,7 +37,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
37
37
|
sections={[]}
|
|
38
38
|
renderItem={({item}) => <item value={item.key} />}
|
|
39
39
|
getItem={(data, key) => data[key]}
|
|
40
|
-
getItemCount={
|
|
40
|
+
getItemCount={data => data.length}
|
|
41
41
|
/>,
|
|
42
42
|
);
|
|
43
43
|
expect(component).toMatchSnapshot();
|
|
@@ -51,7 +51,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
51
51
|
ListFooterComponent={() => <footer />}
|
|
52
52
|
ListHeaderComponent={() => <header />}
|
|
53
53
|
getItem={(data, key) => data[key]}
|
|
54
|
-
getItemCount={
|
|
54
|
+
getItemCount={data => data.length}
|
|
55
55
|
renderItem={({item}) => <item value={item.key} />}
|
|
56
56
|
/>,
|
|
57
57
|
);
|
|
@@ -64,7 +64,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
64
64
|
sections={[{title: 's1', data: [{key: 'hello'}]}]}
|
|
65
65
|
ListEmptyComponent={() => <empty />}
|
|
66
66
|
getItem={(data, key) => data[key]}
|
|
67
|
-
getItemCount={
|
|
67
|
+
getItemCount={data => data.length}
|
|
68
68
|
renderItem={({item}) => <item value={item.key} />}
|
|
69
69
|
/>,
|
|
70
70
|
);
|
|
@@ -85,7 +85,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
85
85
|
},
|
|
86
86
|
]}
|
|
87
87
|
getItem={(data, key) => data[key]}
|
|
88
|
-
getItemCount={
|
|
88
|
+
getItemCount={data => data.length}
|
|
89
89
|
getItemLayout={({index}) => ({
|
|
90
90
|
index: -1,
|
|
91
91
|
length: 50,
|
|
@@ -107,16 +107,16 @@ describe('VirtualizedSectionList', () => {
|
|
|
107
107
|
ReactTestRenderer.act(() => {
|
|
108
108
|
component = ReactTestRenderer.create(
|
|
109
109
|
<VirtualizedSectionList
|
|
110
|
-
ItemSeparatorComponent={
|
|
110
|
+
ItemSeparatorComponent={props => <separator {...props} />}
|
|
111
111
|
sections={[
|
|
112
112
|
{title: 's0', data: [{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]},
|
|
113
113
|
]}
|
|
114
|
-
renderItem={
|
|
114
|
+
renderItem={info => {
|
|
115
115
|
infos.push(info);
|
|
116
116
|
return <item title={info.item.key} />;
|
|
117
117
|
}}
|
|
118
118
|
getItem={(data, key) => data[key]}
|
|
119
|
-
getItemCount={
|
|
119
|
+
getItemCount={data => data.length}
|
|
120
120
|
/>,
|
|
121
121
|
);
|
|
122
122
|
});
|
|
@@ -140,7 +140,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
140
140
|
const component = ReactTestRenderer.create(
|
|
141
141
|
<VirtualizedSectionList
|
|
142
142
|
sections={[{title: 'outer', data: [{key: 'outer0'}, {key: 'outer1'}]}]}
|
|
143
|
-
renderItem={
|
|
143
|
+
renderItem={outerInfo => (
|
|
144
144
|
<VirtualizedSectionList
|
|
145
145
|
sections={[
|
|
146
146
|
{
|
|
@@ -152,15 +152,15 @@ describe('VirtualizedSectionList', () => {
|
|
|
152
152
|
},
|
|
153
153
|
]}
|
|
154
154
|
horizontal={outerInfo.item.key === 'outer1'}
|
|
155
|
-
renderItem={
|
|
155
|
+
renderItem={innerInfo => {
|
|
156
156
|
return <item title={innerInfo.item.key} />;
|
|
157
157
|
}}
|
|
158
158
|
getItem={(data, key) => data[key]}
|
|
159
|
-
getItemCount={
|
|
159
|
+
getItemCount={data => data.length}
|
|
160
160
|
/>
|
|
161
161
|
)}
|
|
162
162
|
getItem={(data, key) => data[key]}
|
|
163
|
-
getItemCount={
|
|
163
|
+
getItemCount={data => data.length}
|
|
164
164
|
/>,
|
|
165
165
|
);
|
|
166
166
|
expect(component).toMatchSnapshot();
|
|
@@ -169,7 +169,9 @@ describe('VirtualizedSectionList', () => {
|
|
|
169
169
|
describe('scrollToLocation', () => {
|
|
170
170
|
const ITEM_HEIGHT = 100;
|
|
171
171
|
|
|
172
|
-
const createVirtualizedSectionList = (
|
|
172
|
+
const createVirtualizedSectionList = (
|
|
173
|
+
props: void | $TEMPORARY$object<{stickySectionHeadersEnabled: boolean}>,
|
|
174
|
+
) => {
|
|
173
175
|
const component = ReactTestRenderer.create(
|
|
174
176
|
<VirtualizedSectionList
|
|
175
177
|
sections={[
|
|
@@ -178,7 +180,7 @@ describe('VirtualizedSectionList', () => {
|
|
|
178
180
|
]}
|
|
179
181
|
renderItem={({item}) => <item value={item.key} />}
|
|
180
182
|
getItem={(data, key) => data[key]}
|
|
181
|
-
getItemCount={
|
|
183
|
+
getItemCount={data => data.length}
|
|
182
184
|
getItemLayout={(data, index) => ({
|
|
183
185
|
length: ITEM_HEIGHT,
|
|
184
186
|
offset: ITEM_HEIGHT * index,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -156,7 +156,7 @@ function appendNewLog(newLog) {
|
|
|
156
156
|
// sybolication for up to a second before adding the log.
|
|
157
157
|
const OPTIMISTIC_WAIT_TIME = 1000;
|
|
158
158
|
|
|
159
|
-
let addPendingLog = () => {
|
|
159
|
+
let addPendingLog: ?() => void = () => {
|
|
160
160
|
logs.add(newLog);
|
|
161
161
|
if (_selectedIndex < 0) {
|
|
162
162
|
setSelectedLog(logs.size - 1);
|