@office-iss/react-native-win32 0.68.0 → 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.
Files changed (180) hide show
  1. package/.flowconfig +1 -3
  2. package/CHANGELOG.json +356 -32
  3. package/CHANGELOG.md +150 -19
  4. package/IntegrationTests/BUCK +4 -1
  5. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -0
  6. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
  7. package/Libraries/Alert/Alert.win32.js +1 -1
  8. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  9. package/Libraries/Animated/NativeAnimatedHelper.js +55 -9
  10. package/Libraries/Animated/NativeAnimatedModule.js +1 -0
  11. package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
  12. package/Libraries/Animated/animations/TimingAnimation.js +6 -11
  13. package/Libraries/Animated/createAnimatedComponent.js +2 -2
  14. package/Libraries/Animated/nodes/AnimatedColor.js +95 -29
  15. package/Libraries/Animated/nodes/AnimatedInterpolation.js +19 -22
  16. package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
  17. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  18. package/Libraries/AppState/AppState.js +1 -1
  19. package/Libraries/Blob/URL.js +7 -1
  20. package/Libraries/Components/Button.js +3 -0
  21. package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +5 -0
  22. package/Libraries/Components/Pressable/Pressable.js +3 -3
  23. package/Libraries/Components/Pressable/Pressable.win32.js +3 -3
  24. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +47 -38
  25. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +15 -7
  26. package/Libraries/Components/ScrollView/ScrollView.js +1 -1
  27. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -3
  28. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
  29. package/Libraries/Components/Slider/Slider.js +0 -2
  30. package/Libraries/Components/Slider/SliderNativeComponent.js +0 -1
  31. package/Libraries/Components/StatusBar/StatusBar.js +6 -1
  32. package/Libraries/Components/Switch/Switch.js +11 -1
  33. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +114 -109
  34. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +17 -9
  35. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +13 -5
  36. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
  37. package/Libraries/Components/TextInput/TextInput.js +1 -8
  38. package/Libraries/Components/TextInput/TextInputState.js +10 -2
  39. package/Libraries/Components/TextInput/TextInputState.win32.js +10 -2
  40. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  41. package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
  42. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -0
  43. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -0
  44. package/Libraries/Components/Touchable/TouchableOpacity.js +7 -1
  45. package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +3 -1
  46. package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
  47. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -0
  48. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  49. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  50. package/Libraries/Components/View/View.win32.js +33 -1
  51. package/Libraries/Components/View/ViewNativeComponent.js +68 -8
  52. package/Libraries/Components/View/ViewPropTypes.js +36 -4
  53. package/Libraries/Components/View/ViewPropTypes.win32.js +36 -4
  54. package/Libraries/Components/View/ViewWin32.Props.d.ts +1 -1
  55. package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
  56. package/Libraries/Core/Devtools/parseHermesStack.js +1 -1
  57. package/Libraries/Core/ExceptionsManager.js +1 -1
  58. package/Libraries/Core/RawEventEmitter.js +38 -0
  59. package/Libraries/Core/ReactNativeVersion.js +2 -2
  60. package/Libraries/Core/polyfillPromise.js +32 -0
  61. package/Libraries/Core/setUpReactDevTools.js +3 -2
  62. package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
  63. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
  64. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -3
  65. package/Libraries/Events/CustomEvent.js +32 -0
  66. package/Libraries/Events/EventPolyfill.js +239 -0
  67. package/Libraries/Image/Image.android.js +0 -6
  68. package/Libraries/Image/Image.ios.js +0 -6
  69. package/Libraries/Image/Image.win32.js +2 -8
  70. package/Libraries/Image/ImageViewNativeComponent.js +18 -3
  71. package/Libraries/Image/TextInlineImageNativeComponent.js +23 -15
  72. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  73. package/Libraries/Inspector/Inspector.js +2 -4
  74. package/Libraries/Inspector/Inspector.win32.js +7 -9
  75. package/Libraries/Interaction/BridgeSpyStallHandler.js +4 -3
  76. package/Libraries/Interaction/InteractionManager.js +1 -12
  77. package/Libraries/Interaction/TaskQueue.js +5 -4
  78. package/Libraries/LayoutAnimation/LayoutAnimation.js +13 -0
  79. package/Libraries/Linking/Linking.js +1 -1
  80. package/Libraries/Lists/FlatList.js +27 -6
  81. package/Libraries/Lists/VirtualizedList.js +71 -55
  82. package/Libraries/Lists/VirtualizedListContext.js +7 -3
  83. package/Libraries/Lists/VirtualizedSectionList.js +2 -2
  84. package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
  85. package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
  86. package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
  87. package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
  88. package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +92 -43
  89. package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +16 -14
  90. package/Libraries/LogBox/Data/LogBoxData.js +2 -2
  91. package/Libraries/LogBox/Data/LogBoxLog.js +1 -1
  92. package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
  93. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  94. package/Libraries/LogBox/LogBox.js +2 -21
  95. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -0
  96. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +2 -1
  97. package/Libraries/NativeComponent/BaseViewConfig.android.js +295 -0
  98. package/Libraries/NativeComponent/BaseViewConfig.ios.js +333 -0
  99. package/Libraries/NativeComponent/BaseViewConfig.win32.js +334 -0
  100. package/Libraries/NativeComponent/NativeComponentRegistry.js +0 -2
  101. package/Libraries/NativeComponent/PlatformBaseViewConfig.js +24 -0
  102. package/Libraries/NativeComponent/StaticViewConfigValidator.js +7 -42
  103. package/Libraries/NativeComponent/ViewConfig.js +4 -4
  104. package/Libraries/NativeComponent/ViewConfigIgnore.js +54 -0
  105. package/Libraries/Network/FormData.js +7 -1
  106. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  107. package/Libraries/Pressability/Pressability.js +115 -46
  108. package/Libraries/Pressability/Pressability.win32.js +174 -69
  109. package/Libraries/Pressability/PressabilityDebug.js +5 -9
  110. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
  111. package/Libraries/ReactNative/AppContainer.js +1 -1
  112. package/Libraries/ReactNative/{DummyUIManager.js → BridgelessUIManager.js} +62 -40
  113. package/Libraries/ReactNative/PaperUIManager.win32.js +5 -5
  114. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +39 -0
  115. package/Libraries/ReactNative/UIManager.js +2 -3
  116. package/Libraries/ReactNative/renderApplication.js +4 -0
  117. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +8 -0
  118. package/Libraries/Renderer/implementations/ReactFabric-dev.js +5908 -4906
  119. package/Libraries/Renderer/implementations/ReactFabric-prod.js +2100 -1918
  120. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2567 -2352
  121. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5610 -4844
  122. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1710 -1556
  123. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1830 -1639
  124. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  125. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
  126. package/Libraries/StyleSheet/EdgeInsetsPropType.js +4 -1
  127. package/Libraries/StyleSheet/StyleSheetTypes.js +59 -66
  128. package/Libraries/StyleSheet/normalizeColor.js +1 -1
  129. package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +15 -0
  130. package/Libraries/StyleSheet/private/_TransformStyle.js +53 -0
  131. package/Libraries/Text/Text.js +13 -7
  132. package/Libraries/Text/TextNativeComponent.js +2 -0
  133. package/Libraries/Text/TextNativeComponent.win32.js +2 -0
  134. package/Libraries/Text/TextProps.js +10 -0
  135. package/Libraries/Types/CoreEventTypes.js +13 -1
  136. package/Libraries/Types/CoreEventTypes.win32.js +26 -1
  137. package/Libraries/Utilities/Appearance.js +0 -8
  138. package/Libraries/Utilities/HMRClient.js +1 -1
  139. package/Libraries/Utilities/ReactNativeTestTools.js +1 -0
  140. package/Libraries/Utilities/codegenNativeComponent.js +17 -6
  141. package/Libraries/Utilities/stringifySafe.js +4 -1
  142. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +3 -3
  143. package/Libraries/WebSocket/WebSocket.js +1 -1
  144. package/Libraries/vendor/emitter/_EmitterSubscription.js +1 -1
  145. package/Libraries/vendor/emitter/_EventEmitter.js +1 -1
  146. package/Libraries/vendor/emitter/_EventSubscription.js +1 -1
  147. package/index.js +30 -25
  148. package/index.win32.js +30 -25
  149. package/jest/preprocessor.js +24 -107
  150. package/jest/preprocessor_DO_NOT_USE.js +122 -0
  151. package/metro.config.js +3 -47
  152. package/overrides.json +39 -46
  153. package/package.json +30 -29
  154. package/rntypes/index.d.ts +19 -7
  155. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +1 -1
  156. package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +3 -1
  157. package/src/Libraries/Components/View/ViewWin32.Props.ts +1 -0
  158. package/src/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +427 -0
  159. package/src/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +391 -0
  160. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap +3 -0
  161. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +4565 -0
  162. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +1153 -0
  163. package/src/rntypes/index.d.ts +19 -7
  164. package/typings-index.js +5 -1
  165. package/typings-index.js.map +1 -1
  166. package/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +0 -44
  167. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +0 -45
  168. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +0 -123
  169. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.js +0 -45
  170. package/Libraries/Components/View/ReactNativeViewViewConfig.js +0 -360
  171. package/Libraries/Components/View/ReactNativeViewViewConfig.win32.js +0 -401
  172. package/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +0 -83
  173. package/Libraries/ReactNative/UIManagerInjection.js +0 -15
  174. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +0 -24527
  175. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +0 -8309
  176. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +0 -8961
  177. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +0 -24948
  178. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +0 -8400
  179. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +0 -9049
  180. 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
- // $FlowFixMe[prop-missing] Cannot access private property
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: (data2) => data2.length,
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((listener) =>
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={(outerInfo) => (
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={(innerInfo) => {
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={(props) => (
42
+ ItemSeparatorComponent={props => (
43
43
  <defaultItemSeparator v={propStr(props)} />
44
44
  )}
45
- ListEmptyComponent={(props) => <empty v={propStr(props)} />}
46
- ListFooterComponent={(props) => <footer v={propStr(props)} />}
47
- ListHeaderComponent={(props) => <header v={propStr(props)} />}
48
- SectionSeparatorComponent={(props) => (
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: (props) => <itemForSection1 v={propStr(props)} />,
53
+ renderItem: props => <itemForSection1 v={propStr(props)} />,
54
54
  key: 's1',
55
55
  keyExtractor: (item, index) => item.id,
56
- ItemSeparatorComponent: (props) => (
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={(props) => <defaultItem v={propStr(props)} />}
73
- renderSectionHeader={(props) => <sectionHeader v={propStr(props)} />}
74
- renderSectionFooter={(props) => <sectionFooter v={propStr(props)} />}
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={(props) => <sectionHeader v={propStr(props)} />}
85
- renderSectionFooter={(props) => <sectionFooter v={propStr(props)} />}
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={(props) => <sectionFooter v={propStr(props)} />}
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((k) => {
104
+ .map(k => {
105
105
  const propObj = props[k] || {};
106
106
  return `${k}:${propObj.key || propObj.id || props[k]}`;
107
107
  })
@@ -62,7 +62,7 @@ describe('elementsThatOverlapOffsets', function () {
62
62
  {offset: 950, length: 150},
63
63
  ];
64
64
  expect(
65
- elementsThatOverlapOffsets(offsets, frames.length, (ii) => frames[ii]),
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, (ii) => frames[ii]),
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, (ii) => frames[ii]);
87
+ elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]);
88
88
  }).toThrowErrorMatchingSnapshot();
89
89
  });
90
90
  });
@@ -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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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((message) => {
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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={(data) => 0}
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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={(props) => <separator {...props} />}
206
+ ItemSeparatorComponent={props => <separator {...props} />}
207
207
  data={[{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]}
208
- renderItem={(info) => {
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={(data) => data.length}
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={(outerInfo) => (
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={(innerInfo) => {
235
+ renderItem={innerInfo => {
236
236
  return <item title={innerInfo.item.key} />;
237
237
  }}
238
238
  getItem={(data, index) => data[index]}
239
- getItemCount={(data) => data.length}
239
+ getItemCount={data => data.length}
240
240
  />
241
241
  )}
242
242
  getItem={(data, index) => data[index]}
243
- getItemCount={(data) => data.length}
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: (items) => items.length,
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={(data) => data.length}
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={(outerInfo) => (
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={(innerInfo) => {
340
+ renderItem={innerInfo => {
341
341
  return <item title={innerInfo.item.key} />;
342
342
  }}
343
343
  getItem={(data, index) => data[index]}
344
- getItemCount={(data) => data.length}
344
+ getItemCount={data => data.length}
345
345
  ref={listRef}
346
346
  />
347
347
  )}
348
348
  getItem={(data, index) => data[index]}
349
- getItemCount={(data) => data.length}
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((_, key) => ({key: String(key)}));
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: (items) => items.length,
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: (data) => data.length,
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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('does not adjust render area with non-zero initialScrollIndex until scrolled', () => {
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
- // Layout information from before the time we scroll to initial index may not
892
- // correspond to the area "initialScrollIndex" points to. Expect only the 5
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('adjusts render area with non-zero initialScrollIndex after scrolled', () => {
899
- const items = generateItems(20);
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
- simulateScroll(component, {x: 0, y: 10});
938
+ ReactTestRenderer.act(() => {
923
939
  performAllBatches();
924
940
  });
925
941
 
926
- // We should expand the render area after receiving a message indcating 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: (data) => data.length,
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((item) => item.sticky).map((item) => item.key);
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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={(data) => data.length}
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={(props) => <separator {...props} />}
110
+ ItemSeparatorComponent={props => <separator {...props} />}
111
111
  sections={[
112
112
  {title: 's0', data: [{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]},
113
113
  ]}
114
- renderItem={(info) => {
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={(data) => data.length}
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={(outerInfo) => (
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={(innerInfo) => {
155
+ renderItem={innerInfo => {
156
156
  return <item title={innerInfo.item.key} />;
157
157
  }}
158
158
  getItem={(data, key) => data[key]}
159
- getItemCount={(data) => data.length}
159
+ getItemCount={data => data.length}
160
160
  />
161
161
  )}
162
162
  getItem={(data, key) => data[key]}
163
- getItemCount={(data) => data.length}
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 = (props) => {
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={(data) => data.length}
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-local
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);