@react-native-tvos/virtualized-lists 0.75.2-0rc1 → 0.76.0-0rc1

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.
@@ -940,7 +940,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
940
940
  // 2a. Add a cell for ListEmptyComponent if applicable
941
941
  const itemCount = this.props.getItemCount(data);
942
942
  if (itemCount === 0 && ListEmptyComponent) {
943
- const element: React.Element<any> = ((React.isValidElement(
943
+ const element: ExactReactElement_DEPRECATED<any> = ((React.isValidElement(
944
944
  ListEmptyComponent,
945
945
  ) ? (
946
946
  ListEmptyComponent
@@ -1863,7 +1863,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
1863
1863
  _updateCellsToRender = () => {
1864
1864
  this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1865
1865
 
1866
- this.setState((state, props) => {
1866
+ this.setState((state, props: any) => {
1867
1867
  const cellsAroundViewport = this._adjustCellsAroundViewport(
1868
1868
  props,
1869
1869
  state.cellsAroundViewport,
@@ -1908,12 +1908,14 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
1908
1908
  }
1909
1909
 
1910
1910
  _getNonViewportRenderRegions = (
1911
- props: CellMetricProps,
1911
+ props: CellMetricProps & {
1912
+ additionalRenderRegions?: {first: number, last: number}[],
1913
+ },
1912
1914
  ): $ReadOnlyArray<{
1913
1915
  first: number,
1914
1916
  last: number,
1915
1917
  }> => {
1916
- let nonViewportRenderRegions = [];
1918
+ let nonViewportRenderRegions: {first: number, last: number}[] = [];
1917
1919
 
1918
1920
  if (props?.additionalRenderRegions?.length) {
1919
1921
  nonViewportRenderRegions = [...props.additionalRenderRegions];
@@ -8,6 +8,7 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';
11
12
  import type {CellRendererProps, RenderItemType} from './VirtualizedListProps';
12
13
  import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
13
14
  import type {
@@ -25,7 +26,7 @@ export type Props<ItemT> = {
25
26
  ItemSeparatorComponent: ?React.ComponentType<
26
27
  any | {highlighted: boolean, leadingItem: ?ItemT},
27
28
  >,
28
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
29
+ ListItemComponent?: ?(React.ComponentType<any> | React.MixedElement),
29
30
  cellKey: string,
30
31
  horizontal: ?boolean,
31
32
  index: number,
@@ -53,7 +54,7 @@ type State<ItemT> = {
53
54
  ...
54
55
  };
55
56
 
56
- export default class CellRenderer<ItemT> extends React.Component<
57
+ export default class CellRenderer<ItemT> extends React.PureComponent<
57
58
  Props<ItemT>,
58
59
  State<ItemT>,
59
60
  > {
@@ -68,12 +69,24 @@ export default class CellRenderer<ItemT> extends React.Component<
68
69
  props: Props<ItemT>,
69
70
  prevState: State<ItemT>,
70
71
  ): ?State<ItemT> {
71
- return {
72
- separatorProps: {
73
- ...prevState.separatorProps,
74
- leadingItem: props.item,
75
- },
76
- };
72
+ if (ReactNativeFeatureFlags.enableOptimisedVirtualizedCells()) {
73
+ if (props.item !== prevState.separatorProps.leadingItem) {
74
+ return {
75
+ separatorProps: {
76
+ ...prevState.separatorProps,
77
+ leadingItem: props.item,
78
+ },
79
+ };
80
+ }
81
+ return null;
82
+ } else {
83
+ return {
84
+ separatorProps: {
85
+ ...prevState.separatorProps,
86
+ leadingItem: props.item,
87
+ },
88
+ };
89
+ }
77
90
  }
78
91
 
79
92
  // TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
@@ -155,17 +155,26 @@ type OptionalProps = {|
155
155
  * `highlight` and `unhighlight` (which set the `highlighted: boolean` prop) are insufficient for
156
156
  * your use-case.
157
157
  */
158
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
158
+ ListItemComponent?: ?(
159
+ | React.ComponentType<any>
160
+ | ExactReactElement_DEPRECATED<any>
161
+ ),
159
162
  /**
160
163
  * Rendered when the list is empty. Can be a React Component Class, a render function, or
161
164
  * a rendered element.
162
165
  */
163
- ListEmptyComponent?: ?(React.ComponentType<any> | React.Element<any>),
166
+ ListEmptyComponent?: ?(
167
+ | React.ComponentType<any>
168
+ | ExactReactElement_DEPRECATED<any>
169
+ ),
164
170
  /**
165
171
  * Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
166
172
  * a rendered element.
167
173
  */
168
- ListFooterComponent?: ?(React.ComponentType<any> | React.Element<any>),
174
+ ListFooterComponent?: ?(
175
+ | React.ComponentType<any>
176
+ | ExactReactElement_DEPRECATED<any>
177
+ ),
169
178
  /**
170
179
  * Styling for internal View for ListFooterComponent
171
180
  */
@@ -174,7 +183,10 @@ type OptionalProps = {|
174
183
  * Rendered at the top of all the items. Can be a React Component Class, a render function, or
175
184
  * a rendered element.
176
185
  */
177
- ListHeaderComponent?: ?(React.ComponentType<any> | React.Element<any>),
186
+ ListHeaderComponent?: ?(
187
+ | React.ComponentType<any>
188
+ | ExactReactElement_DEPRECATED<any>
189
+ ),
178
190
  /**
179
191
  * Styling for internal View for ListHeaderComponent
180
192
  */
@@ -244,7 +256,7 @@ type OptionalProps = {|
244
256
  * <RefreshControl> component built internally. The onRefresh and refreshing
245
257
  * props are also ignored. Only works for vertical VirtualizedList.
246
258
  */
247
- refreshControl?: ?React.Element<any>,
259
+ refreshControl?: ?ExactReactElement_DEPRECATED<any>,
248
260
  /**
249
261
  * Set this true while waiting for new data from a refresh.
250
262
  */
@@ -258,7 +270,7 @@ type OptionalProps = {|
258
270
  /**
259
271
  * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
260
272
  */
261
- renderScrollComponent?: (props: Object) => React.Element<any>,
273
+ renderScrollComponent?: (props: Object) => ExactReactElement_DEPRECATED<any>,
262
274
  /**
263
275
  * Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
264
276
  * screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
@@ -38,7 +38,7 @@ export type SectionBase<SectionItemT> = {
38
38
  ...
39
39
  },
40
40
  ...
41
- }) => null | React.Element<any>,
41
+ }) => null | React.MixedElement,
42
42
  ItemSeparatorComponent?: ?React.ComponentType<any>,
43
43
  keyExtractor?: (item: SectionItemT, index?: ?number) => string,
44
44
  ...
@@ -63,22 +63,16 @@ type OptionalProps<SectionT: SectionBase<any>> = {|
63
63
  ...
64
64
  },
65
65
  ...
66
- }) => null | React.Element<any>,
66
+ }) => null | React.Node,
67
67
  /**
68
68
  * Rendered at the top of each section. These stick to the top of the `ScrollView` by default on
69
69
  * iOS. See `stickySectionHeadersEnabled`.
70
70
  */
71
- renderSectionHeader?: ?(info: {
72
- section: SectionT,
73
- ...
74
- }) => null | React.Element<any>,
71
+ renderSectionHeader?: ?(info: {section: SectionT, ...}) => null | React.Node,
75
72
  /**
76
73
  * Rendered at the bottom of each section.
77
74
  */
78
- renderSectionFooter?: ?(info: {
79
- section: SectionT,
80
- ...
81
- }) => null | React.Element<any>,
75
+ renderSectionFooter?: ?(info: {section: SectionT, ...}) => null | React.Node,
82
76
  /**
83
77
  * Rendered at the top and bottom of each section (note this is different from
84
78
  * `ItemSeparatorComponent` which is only rendered between items). These are intended to separate
@@ -453,8 +447,8 @@ class VirtualizedSectionList<
453
447
 
454
448
  _updateHighlightMap: {[string]: (boolean) => void} = {};
455
449
  _updatePropsMap: {[string]: void | (boolean => void)} = {};
456
- _listRef: ?React.ElementRef<typeof VirtualizedList>;
457
- _captureRef = (ref: null | React$ElementRef<Class<VirtualizedList>>) => {
450
+ _listRef: ?VirtualizedList;
451
+ _captureRef = (ref: null | VirtualizedList) => {
458
452
  this._listRef = ref;
459
453
  };
460
454
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-tvos/virtualized-lists",
3
- "version": "0.75.2-0rc1",
3
+ "version": "0.76.0-0rc1",
4
4
  "description": "Virtualized lists for React Native.",
5
5
  "license": "MIT",
6
6
  "repository": {