Skip to content

Commit 0a0b48b

Browse files
huntiefacebook-github-bot
authored andcommitted
Expose ListViewToken type as root export (#53539)
Summary: Pull Request resolved: #53539 Resolves react-native-community/discussions-and-proposals#893 (comment). Changelog: [General][Added] - `ListViewToken` is now exposed when using `"react-native-strict-api"` Reviewed By: rshest Differential Revision: D81380882 fbshipit-source-id: 1da5c50eaec2f8dc4a8cde60e7441249556053a8
1 parent 46278e3 commit 0a0b48b

File tree

6 files changed

+34
-31
lines changed

6 files changed

+34
-31
lines changed

packages/react-native/Libraries/Lists/FlatList.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
1313
import type {
1414
ListRenderItem,
1515
ListRenderItemInfo,
16+
ListViewToken,
1617
ViewabilityConfigCallbackPair,
17-
ViewToken,
1818
VirtualizedListProps,
1919
} from '@react-native/virtualized-lists';
2020

@@ -573,7 +573,7 @@ class FlatList<ItemT = any> extends React.PureComponent<FlatListProps<ItemT>> {
573573
return keyExtractor(items, index);
574574
};
575575

576-
_pushMultiColumnViewable(arr: Array<ViewToken>, v: ViewToken): void {
576+
_pushMultiColumnViewable(arr: Array<ListViewToken>, v: ListViewToken): void {
577577
const numColumns = numColumnsOrDefault(this.props.numColumns);
578578
const keyExtractor = this.props.keyExtractor ?? defaultKeyExtractor;
579579
v.item.forEach((item, ii) => {
@@ -585,22 +585,22 @@ class FlatList<ItemT = any> extends React.PureComponent<FlatListProps<ItemT>> {
585585

586586
_createOnViewableItemsChanged(
587587
onViewableItemsChanged: ?(info: {
588-
viewableItems: Array<ViewToken>,
589-
changed: Array<ViewToken>,
588+
viewableItems: Array<ListViewToken>,
589+
changed: Array<ListViewToken>,
590590
...
591591
}) => void,
592592
// $FlowFixMe[missing-local-annot]
593593
) {
594594
return (info: {
595-
viewableItems: Array<ViewToken>,
596-
changed: Array<ViewToken>,
595+
viewableItems: Array<ListViewToken>,
596+
changed: Array<ListViewToken>,
597597
...
598598
}) => {
599599
const numColumns = numColumnsOrDefault(this.props.numColumns);
600600
if (onViewableItemsChanged) {
601601
if (numColumns > 1) {
602-
const changed: Array<ViewToken> = [];
603-
const viewableItems: Array<ViewToken> = [];
602+
const changed: Array<ListViewToken> = [];
603+
const viewableItems: Array<ListViewToken> = [];
604604
info.viewableItems.forEach(v =>
605605
this._pushMultiColumnViewable(viewableItems, v),
606606
);

packages/react-native/Libraries/Lists/ViewabilityHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
export type {
14-
ViewToken,
14+
ListViewToken as ViewToken,
1515
ViewabilityConfig,
1616
ViewabilityConfigCallbackPair,
1717
} from '@react-native/virtualized-lists';

packages/react-native/Libraries/Lists/VirtualizedList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const VirtualizedListComponent: VirtualizedListType =
1919
export type {
2020
ListRenderItemInfo,
2121
ListRenderItem,
22+
ListViewToken,
2223
Separators,
2324
VirtualizedListProps,
2425
} from '@react-native/virtualized-lists';

packages/react-native/ReactNativeApi.d.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<db6de028840aefaf5eeb3e2cec029553>>
7+
* @generated SignedSource<<0a0286ba0bc29af2abd2e8fd836077fb>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -3089,6 +3089,13 @@ declare type ListRenderItemInfo<ItemT> = {
30893089
item: ItemT
30903090
separators: Separators
30913091
}
3092+
declare type ListViewToken = {
3093+
index: number | undefined
3094+
isViewable: boolean
3095+
item: any
3096+
key: string
3097+
section?: any
3098+
}
30923099
declare type LogBox = typeof LogBox
30933100
declare type LogData = {
30943101
readonly category: Category
@@ -3511,8 +3518,8 @@ declare type OptionalVirtualizedListProps = {
35113518
onStartReached?: (info: { distanceFromStart: number }) => void
35123519
onStartReachedThreshold?: number
35133520
onViewableItemsChanged?: (info: {
3514-
changed: Array<ViewToken>
3515-
viewableItems: Array<ViewToken>
3521+
changed: Array<ListViewToken>
3522+
viewableItems: Array<ListViewToken>
35163523
}) => void
35173524
persistentScrollbar?: boolean
35183525
progressViewOffset?: number
@@ -5679,8 +5686,8 @@ declare type ViewabilityConfig = {
56795686
declare type ViewabilityConfigCallbackPair = {
56805687
viewabilityConfig: ViewabilityConfig
56815688
onViewableItemsChanged: (info: {
5682-
changed: Array<ViewToken>
5683-
viewableItems: Array<ViewToken>
5689+
changed: Array<ListViewToken>
5690+
viewableItems: Array<ListViewToken>
56845691
}) => void
56855692
}
56865693
declare class ViewabilityHelper_default {
@@ -5705,10 +5712,10 @@ declare class ViewabilityHelper_default {
57055712
index: number,
57065713
isViewable: boolean,
57075714
props: CellMetricProps,
5708-
) => ViewToken,
5715+
) => ListViewToken,
57095716
onViewableItemsChanged: ($$PARAM_0$$: {
5710-
changed: Array<ViewToken>
5711-
viewableItems: Array<ViewToken>
5717+
changed: Array<ListViewToken>
5718+
viewableItems: Array<ListViewToken>
57125719
}) => void,
57135720
renderRange?: {
57145721
first: number
@@ -5793,13 +5800,6 @@ declare type ViewPropsIOS = {
57935800
}
57945801
declare type ViewStyle = ____ViewStyle_Internal
57955802
declare type ViewStyleProp = ____ViewStyleProp_Internal
5796-
declare type ViewToken = {
5797-
index: number | undefined
5798-
isViewable: boolean
5799-
item: any
5800-
key: string
5801-
section?: any
5802-
}
58035803
declare type VirtualizedList = typeof VirtualizedList
58045804
declare class VirtualizedList_default extends StateSafePureComponent_default<
58055805
VirtualizedListProps,
@@ -6013,8 +6013,8 @@ export {
60136013
EventSubscription, // b8d084aa
60146014
ExtendedExceptionData, // 5a6ccf5a
60156015
FilterFunction, // bf24c0e3
6016-
FlatList, // 714df8ad
6017-
FlatListProps, // e3e724ea
6016+
FlatList, // 4f1b407e
6017+
FlatListProps, // b225fb7a
60186018
FocusEvent, // 529b43eb
60196019
FontVariant, // 7c7558bb
60206020
GestureResponderEvent, // b466f6d6
@@ -6068,6 +6068,7 @@ export {
60686068
Linking, // 292de0a0
60696069
ListRenderItem, // b5353fd8
60706070
ListRenderItemInfo, // e8595b03
6071+
ListViewToken, // 833d3481
60716072
LogBox, // b58880c6
60726073
LogData, // 89af6d4c
60736074
MeasureInWindowOnSuccessCallback, // a285f598
@@ -6151,9 +6152,9 @@ export {
61516152
ScrollViewPropsIOS, // d83c9733
61526153
ScrollViewScrollToOptions, // 3313411e
61536154
SectionBase, // 0ccaedac
6154-
SectionList, // cc6dec0b
6155+
SectionList, // a1a4786b
61556156
SectionListData, // 1c80bb2e
6156-
SectionListProps, // 97fcf95a
6157+
SectionListProps, // 7fb5371e
61576158
SectionListRenderItem, // cffebb53
61586159
SectionListRenderItemInfo, // 946c2128
61596160
Separators, // 6a45f7e3
@@ -6218,9 +6219,9 @@ export {
62186219
ViewStyle, // c2db0e6e
62196220
VirtualViewMode, // 85a69ef6
62206221
VirtualizedList, // 4d513939
6221-
VirtualizedListProps, // 8efa6d8e
6222+
VirtualizedListProps, // be716140
62226223
VirtualizedSectionList, // 446ba0df
6223-
VirtualizedSectionListProps, // c5e64f83
6224+
VirtualizedSectionListProps, // a6899dfb
62246225
WrapperComponentProvider, // 9cf3844c
62256226
codegenNativeCommands, // e16d62f7
62266227
codegenNativeComponent, // ed4c8103

packages/react-native/index.js.flow

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export {default as View} from './Libraries/Components/View/View';
184184
export type {
185185
ListRenderItemInfo,
186186
ListRenderItem,
187+
ListViewToken,
187188
Separators,
188189
VirtualizedListProps,
189190
} from './Libraries/Lists/VirtualizedList';

packages/virtualized-lists/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {typeof VirtualizedListContextResetter as VirtualizedListContextResetterT
1919
import {keyExtractor} from './Lists/VirtualizeUtils';
2020

2121
export type {
22-
ViewToken,
22+
ViewToken as ListViewToken,
2323
ViewabilityConfig,
2424
ViewabilityConfigCallbackPair,
2525
ViewabilityConfigCallbackPairs,

0 commit comments

Comments
 (0)