@react-native/virtualized-lists 0.72.0

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.
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ * @format
9
+ */
10
+
11
+ import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
12
+ import type {
13
+ FocusEvent,
14
+ LayoutEvent,
15
+ } from 'react-native/Libraries/Types/CoreEventTypes';
16
+ import type FillRateHelper from './FillRateHelper';
17
+ import type {RenderItemType} from './VirtualizedListProps';
18
+
19
+ import {View, StyleSheet} from 'react-native';
20
+ import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
21
+ import invariant from 'invariant';
22
+ import * as React from 'react';
23
+
24
+ export type Props<ItemT> = {
25
+ CellRendererComponent?: ?React.ComponentType<any>,
26
+ ItemSeparatorComponent: ?React.ComponentType<
27
+ any | {highlighted: boolean, leadingItem: ?ItemT},
28
+ >,
29
+ ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
30
+ cellKey: string,
31
+ debug?: ?boolean,
32
+ fillRateHelper: FillRateHelper,
33
+ getItemLayout?: (
34
+ data: any,
35
+ index: number,
36
+ ) => {
37
+ length: number,
38
+ offset: number,
39
+ index: number,
40
+ ...
41
+ },
42
+ horizontal: ?boolean,
43
+ index: number,
44
+ inversionStyle: ViewStyleProp,
45
+ item: ItemT,
46
+ onCellLayout: (event: LayoutEvent, cellKey: string, index: number) => void,
47
+ onCellFocusCapture?: (event: FocusEvent) => void,
48
+ onUnmount: (cellKey: string) => void,
49
+ onUpdateSeparators: (
50
+ cellKeys: Array<?string>,
51
+ props: $Shape<SeparatorProps<ItemT>>,
52
+ ) => void,
53
+ prevCellKey: ?string,
54
+ renderItem?: ?RenderItemType<ItemT>,
55
+ ...
56
+ };
57
+
58
+ type SeparatorProps<ItemT> = $ReadOnly<{|
59
+ highlighted: boolean,
60
+ leadingItem: ?ItemT,
61
+ |}>;
62
+
63
+ type State<ItemT> = {
64
+ separatorProps: SeparatorProps<ItemT>,
65
+ ...
66
+ };
67
+
68
+ export default class CellRenderer<ItemT> extends React.Component<
69
+ Props<ItemT>,
70
+ State<ItemT>,
71
+ > {
72
+ state: State<ItemT> = {
73
+ separatorProps: {
74
+ highlighted: false,
75
+ leadingItem: this.props.item,
76
+ },
77
+ };
78
+
79
+ static getDerivedStateFromProps(
80
+ props: Props<ItemT>,
81
+ prevState: State<ItemT>,
82
+ ): ?State<ItemT> {
83
+ return {
84
+ separatorProps: {
85
+ ...prevState.separatorProps,
86
+ leadingItem: props.item,
87
+ },
88
+ };
89
+ }
90
+
91
+ // TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
92
+ // reused by SectionList and we can keep VirtualizedList simpler.
93
+ // $FlowFixMe[missing-local-annot]
94
+ _separators = {
95
+ highlight: () => {
96
+ const {cellKey, prevCellKey} = this.props;
97
+ this.props.onUpdateSeparators([cellKey, prevCellKey], {
98
+ highlighted: true,
99
+ });
100
+ },
101
+ unhighlight: () => {
102
+ const {cellKey, prevCellKey} = this.props;
103
+ this.props.onUpdateSeparators([cellKey, prevCellKey], {
104
+ highlighted: false,
105
+ });
106
+ },
107
+ updateProps: (
108
+ select: 'leading' | 'trailing',
109
+ newProps: SeparatorProps<ItemT>,
110
+ ) => {
111
+ const {cellKey, prevCellKey} = this.props;
112
+ this.props.onUpdateSeparators(
113
+ [select === 'leading' ? prevCellKey : cellKey],
114
+ newProps,
115
+ );
116
+ },
117
+ };
118
+
119
+ updateSeparatorProps(newProps: SeparatorProps<ItemT>) {
120
+ this.setState(state => ({
121
+ separatorProps: {...state.separatorProps, ...newProps},
122
+ }));
123
+ }
124
+
125
+ componentWillUnmount() {
126
+ this.props.onUnmount(this.props.cellKey);
127
+ }
128
+
129
+ _onLayout = (nativeEvent: LayoutEvent): void => {
130
+ this.props.onCellLayout &&
131
+ this.props.onCellLayout(
132
+ nativeEvent,
133
+ this.props.cellKey,
134
+ this.props.index,
135
+ );
136
+ };
137
+
138
+ _renderElement(
139
+ renderItem: ?RenderItemType<ItemT>,
140
+ ListItemComponent: any,
141
+ item: ItemT,
142
+ index: number,
143
+ ): React.Node {
144
+ if (renderItem && ListItemComponent) {
145
+ console.warn(
146
+ 'VirtualizedList: Both ListItemComponent and renderItem props are present. ListItemComponent will take' +
147
+ ' precedence over renderItem.',
148
+ );
149
+ }
150
+
151
+ if (ListItemComponent) {
152
+ /* $FlowFixMe[not-a-component] (>=0.108.0 site=react_native_fb) This
153
+ * comment suppresses an error found when Flow v0.108 was deployed. To
154
+ * see the error, delete this comment and run Flow. */
155
+ /* $FlowFixMe[incompatible-type-arg] (>=0.108.0 site=react_native_fb)
156
+ * This comment suppresses an error found when Flow v0.108 was deployed.
157
+ * To see the error, delete this comment and run Flow. */
158
+ return React.createElement(ListItemComponent, {
159
+ item,
160
+ index,
161
+ separators: this._separators,
162
+ });
163
+ }
164
+
165
+ if (renderItem) {
166
+ return renderItem({
167
+ item,
168
+ index,
169
+ separators: this._separators,
170
+ });
171
+ }
172
+
173
+ invariant(
174
+ false,
175
+ 'VirtualizedList: Either ListItemComponent or renderItem props are required but none were found.',
176
+ );
177
+ }
178
+
179
+ render(): React.Node {
180
+ const {
181
+ CellRendererComponent,
182
+ ItemSeparatorComponent,
183
+ ListItemComponent,
184
+ debug,
185
+ fillRateHelper,
186
+ getItemLayout,
187
+ horizontal,
188
+ item,
189
+ index,
190
+ inversionStyle,
191
+ onCellFocusCapture,
192
+ renderItem,
193
+ } = this.props;
194
+ const element = this._renderElement(
195
+ renderItem,
196
+ ListItemComponent,
197
+ item,
198
+ index,
199
+ );
200
+
201
+ const onLayout =
202
+ (getItemLayout && !debug && !fillRateHelper.enabled()) ||
203
+ !this.props.onCellLayout
204
+ ? undefined
205
+ : this._onLayout;
206
+ // NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
207
+ // called explicitly by `ScrollViewStickyHeader`.
208
+ const itemSeparator: React.Node = React.isValidElement(
209
+ ItemSeparatorComponent,
210
+ )
211
+ ? // $FlowFixMe[incompatible-type]
212
+ ItemSeparatorComponent
213
+ : // $FlowFixMe[incompatible-type]
214
+ ItemSeparatorComponent && (
215
+ <ItemSeparatorComponent {...this.state.separatorProps} />
216
+ );
217
+ const cellStyle = inversionStyle
218
+ ? horizontal
219
+ ? [styles.rowReverse, inversionStyle]
220
+ : [styles.columnReverse, inversionStyle]
221
+ : horizontal
222
+ ? [styles.row, inversionStyle]
223
+ : inversionStyle;
224
+ const result = !CellRendererComponent ? (
225
+ <View
226
+ style={cellStyle}
227
+ onLayout={onLayout}
228
+ onFocusCapture={onCellFocusCapture}
229
+ /* $FlowFixMe[incompatible-type-arg] (>=0.89.0 site=react_native_fb) *
230
+ This comment suppresses an error found when Flow v0.89 was deployed. *
231
+ To see the error, delete this comment and run Flow. */
232
+ >
233
+ {element}
234
+ {itemSeparator}
235
+ </View>
236
+ ) : (
237
+ <CellRendererComponent
238
+ {...this.props}
239
+ style={cellStyle}
240
+ onLayout={onLayout}
241
+ onFocusCapture={onCellFocusCapture}>
242
+ {element}
243
+ {itemSeparator}
244
+ </CellRendererComponent>
245
+ );
246
+
247
+ return (
248
+ <VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
249
+ {result}
250
+ </VirtualizedListCellContextProvider>
251
+ );
252
+ }
253
+ }
254
+
255
+ const styles = StyleSheet.create({
256
+ row: {
257
+ flexDirection: 'row',
258
+ },
259
+ rowReverse: {
260
+ flexDirection: 'row-reverse',
261
+ },
262
+ columnReverse: {
263
+ flexDirection: 'column-reverse',
264
+ },
265
+ });
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import typeof VirtualizedList from './VirtualizedList';
12
+
13
+ import * as React from 'react';
14
+ import {useContext, useMemo} from 'react';
15
+
16
+ type Context = $ReadOnly<{
17
+ cellKey: ?string,
18
+ getScrollMetrics: () => {
19
+ contentLength: number,
20
+ dOffset: number,
21
+ dt: number,
22
+ offset: number,
23
+ timestamp: number,
24
+ velocity: number,
25
+ visibleLength: number,
26
+ zoomScale: number,
27
+ },
28
+ horizontal: ?boolean,
29
+ getOutermostParentListRef: () => React.ElementRef<VirtualizedList>,
30
+ registerAsNestedChild: ({
31
+ cellKey: string,
32
+ ref: React.ElementRef<VirtualizedList>,
33
+ }) => void,
34
+ unregisterAsNestedChild: ({
35
+ ref: React.ElementRef<VirtualizedList>,
36
+ }) => void,
37
+ }>;
38
+
39
+ export const VirtualizedListContext: React.Context<?Context> =
40
+ React.createContext(null);
41
+ if (__DEV__) {
42
+ VirtualizedListContext.displayName = 'VirtualizedListContext';
43
+ }
44
+
45
+ /**
46
+ * Resets the context. Intended for use by portal-like components (e.g. Modal).
47
+ */
48
+ export function VirtualizedListContextResetter({
49
+ children,
50
+ }: {
51
+ children: React.Node,
52
+ }): React.Node {
53
+ return (
54
+ <VirtualizedListContext.Provider value={null}>
55
+ {children}
56
+ </VirtualizedListContext.Provider>
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Sets the context with memoization. Intended to be used by `VirtualizedList`.
62
+ */
63
+ export function VirtualizedListContextProvider({
64
+ children,
65
+ value,
66
+ }: {
67
+ children: React.Node,
68
+ value: Context,
69
+ }): React.Node {
70
+ // Avoid setting a newly created context object if the values are identical.
71
+ const context = useMemo(
72
+ () => ({
73
+ cellKey: null,
74
+ getScrollMetrics: value.getScrollMetrics,
75
+ horizontal: value.horizontal,
76
+ getOutermostParentListRef: value.getOutermostParentListRef,
77
+ registerAsNestedChild: value.registerAsNestedChild,
78
+ unregisterAsNestedChild: value.unregisterAsNestedChild,
79
+ }),
80
+ [
81
+ value.getScrollMetrics,
82
+ value.horizontal,
83
+ value.getOutermostParentListRef,
84
+ value.registerAsNestedChild,
85
+ value.unregisterAsNestedChild,
86
+ ],
87
+ );
88
+ return (
89
+ <VirtualizedListContext.Provider value={context}>
90
+ {children}
91
+ </VirtualizedListContext.Provider>
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Sets the `cellKey`. Intended to be used by `VirtualizedList` for each cell.
97
+ */
98
+ export function VirtualizedListCellContextProvider({
99
+ cellKey,
100
+ children,
101
+ }: {
102
+ cellKey: string,
103
+ children: React.Node,
104
+ }): React.Node {
105
+ // Avoid setting a newly created context object if the values are identical.
106
+ const currContext = useContext(VirtualizedListContext);
107
+ const context = useMemo(
108
+ () => (currContext == null ? null : {...currContext, cellKey}),
109
+ [currContext, cellKey],
110
+ );
111
+ return (
112
+ <VirtualizedListContext.Provider value={context}>
113
+ {children}
114
+ </VirtualizedListContext.Provider>
115
+ );
116
+ }
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ * @format
9
+ */
10
+
11
+ import {typeof ScrollView} from 'react-native';
12
+ import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
13
+ import type {
14
+ ViewabilityConfig,
15
+ ViewabilityConfigCallbackPair,
16
+ ViewToken,
17
+ } from './ViewabilityHelper';
18
+
19
+ import * as React from 'react';
20
+
21
+ export type Item = any;
22
+
23
+ export type Separators = {
24
+ highlight: () => void,
25
+ unhighlight: () => void,
26
+ updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
27
+ ...
28
+ };
29
+
30
+ export type RenderItemProps<ItemT> = {
31
+ item: ItemT,
32
+ index: number,
33
+ separators: Separators,
34
+ ...
35
+ };
36
+
37
+ export type RenderItemType<ItemT> = (
38
+ info: RenderItemProps<ItemT>,
39
+ ) => React.Node;
40
+
41
+ type RequiredProps = {|
42
+ /**
43
+ * The default accessor functions assume this is an Array<{key: string} | {id: string}> but you can override
44
+ * getItem, getItemCount, and keyExtractor to handle any type of index-based data.
45
+ */
46
+ data?: any,
47
+ /**
48
+ * A generic accessor for extracting an item from any sort of data blob.
49
+ */
50
+ getItem: (data: any, index: number) => ?Item,
51
+ /**
52
+ * Determines how many items are in the data blob.
53
+ */
54
+ getItemCount: (data: any) => number,
55
+ |};
56
+ type OptionalProps = {|
57
+ renderItem?: ?RenderItemType<Item>,
58
+ /**
59
+ * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
60
+ * implementation, but with a significant perf hit.
61
+ */
62
+ debug?: ?boolean,
63
+ /**
64
+ * DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
65
+ * unmounts react instances that are outside of the render window. You should only need to disable
66
+ * this for debugging purposes. Defaults to false.
67
+ */
68
+ disableVirtualization?: ?boolean,
69
+ /**
70
+ * A marker property for telling the list to re-render (since it implements `PureComponent`). If
71
+ * any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
72
+ * `data` prop, stick it here and treat it immutably.
73
+ */
74
+ extraData?: any,
75
+ // e.g. height, y
76
+ getItemLayout?: (
77
+ data: any,
78
+ index: number,
79
+ ) => {
80
+ length: number,
81
+ offset: number,
82
+ index: number,
83
+ ...
84
+ },
85
+ horizontal?: ?boolean,
86
+ /**
87
+ * How many items to render in the initial batch. This should be enough to fill the screen but not
88
+ * much more. Note these items will never be unmounted as part of the windowed rendering in order
89
+ * to improve perceived performance of scroll-to-top actions.
90
+ */
91
+ initialNumToRender?: ?number,
92
+ /**
93
+ * Instead of starting at the top with the first item, start at `initialScrollIndex`. This
94
+ * disables the "scroll to top" optimization that keeps the first `initialNumToRender` items
95
+ * always rendered and immediately renders the items starting at this initial index. Requires
96
+ * `getItemLayout` to be implemented.
97
+ */
98
+ initialScrollIndex?: ?number,
99
+ /**
100
+ * Reverses the direction of scroll. Uses scale transforms of -1.
101
+ */
102
+ inverted?: ?boolean,
103
+ keyExtractor?: ?(item: Item, index: number) => string,
104
+ /**
105
+ * Each cell is rendered using this element. Can be a React Component Class,
106
+ * or a render function. Defaults to using View.
107
+ */
108
+ CellRendererComponent?: ?React.ComponentType<any>,
109
+ /**
110
+ * Rendered in between each item, but not at the top or bottom. By default, `highlighted` and
111
+ * `leadingItem` props are provided. `renderItem` provides `separators.highlight`/`unhighlight`
112
+ * which will update the `highlighted` prop, but you can also add custom props with
113
+ * `separators.updateProps`.
114
+ */
115
+ ItemSeparatorComponent?: ?React.ComponentType<any>,
116
+ /**
117
+ * Takes an item from `data` and renders it into the list. Example usage:
118
+ *
119
+ * <FlatList
120
+ * ItemSeparatorComponent={Platform.OS !== 'android' && ({highlighted}) => (
121
+ * <View style={[style.separator, highlighted && {marginLeft: 0}]} />
122
+ * )}
123
+ * data={[{title: 'Title Text', key: 'item1'}]}
124
+ * ListItemComponent={({item, separators}) => (
125
+ * <TouchableHighlight
126
+ * onPress={() => this._onPress(item)}
127
+ * onShowUnderlay={separators.highlight}
128
+ * onHideUnderlay={separators.unhighlight}>
129
+ * <View style={{backgroundColor: 'white'}}>
130
+ * <Text>{item.title}</Text>
131
+ * </View>
132
+ * </TouchableHighlight>
133
+ * )}
134
+ * />
135
+ *
136
+ * Provides additional metadata like `index` if you need it, as well as a more generic
137
+ * `separators.updateProps` function which let's you set whatever props you want to change the
138
+ * rendering of either the leading separator or trailing separator in case the more common
139
+ * `highlight` and `unhighlight` (which set the `highlighted: boolean` prop) are insufficient for
140
+ * your use-case.
141
+ */
142
+ ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
143
+ /**
144
+ * Rendered when the list is empty. Can be a React Component Class, a render function, or
145
+ * a rendered element.
146
+ */
147
+ ListEmptyComponent?: ?(React.ComponentType<any> | React.Element<any>),
148
+ /**
149
+ * Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
150
+ * a rendered element.
151
+ */
152
+ ListFooterComponent?: ?(React.ComponentType<any> | React.Element<any>),
153
+ /**
154
+ * Styling for internal View for ListFooterComponent
155
+ */
156
+ ListFooterComponentStyle?: ViewStyleProp,
157
+ /**
158
+ * Rendered at the top of all the items. Can be a React Component Class, a render function, or
159
+ * a rendered element.
160
+ */
161
+ ListHeaderComponent?: ?(React.ComponentType<any> | React.Element<any>),
162
+ /**
163
+ * Styling for internal View for ListHeaderComponent
164
+ */
165
+ ListHeaderComponentStyle?: ViewStyleProp,
166
+ /**
167
+ * The maximum number of items to render in each incremental render batch. The more rendered at
168
+ * once, the better the fill rate, but responsiveness may suffer because rendering content may
169
+ * interfere with responding to button taps or other interactions.
170
+ */
171
+ maxToRenderPerBatch?: ?number,
172
+ /**
173
+ * Called once when the scroll position gets within within `onEndReachedThreshold`
174
+ * from the logical end of the list.
175
+ */
176
+ onEndReached?: ?(info: {distanceFromEnd: number, ...}) => void,
177
+ /**
178
+ * How far from the end (in units of visible length of the list) the trailing edge of the
179
+ * list must be from the end of the content to trigger the `onEndReached` callback.
180
+ * Thus, a value of 0.5 will trigger `onEndReached` when the end of the content is
181
+ * within half the visible length of the list.
182
+ */
183
+ onEndReachedThreshold?: ?number,
184
+ /**
185
+ * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
186
+ * sure to also set the `refreshing` prop correctly.
187
+ */
188
+ onRefresh?: ?() => void,
189
+ /**
190
+ * Used to handle failures when scrolling to an index that has not been measured yet. Recommended
191
+ * action is to either compute your own offset and `scrollTo` it, or scroll as far as possible and
192
+ * then try again after more items have been rendered.
193
+ */
194
+ onScrollToIndexFailed?: ?(info: {
195
+ index: number,
196
+ highestMeasuredFrameIndex: number,
197
+ averageItemLength: number,
198
+ ...
199
+ }) => void,
200
+ /**
201
+ * Called once when the scroll position gets within within `onStartReachedThreshold`
202
+ * from the logical start of the list.
203
+ */
204
+ onStartReached?: ?(info: {distanceFromStart: number, ...}) => void,
205
+ /**
206
+ * How far from the start (in units of visible length of the list) the leading edge of the
207
+ * list must be from the start of the content to trigger the `onStartReached` callback.
208
+ * Thus, a value of 0.5 will trigger `onStartReached` when the start of the content is
209
+ * within half the visible length of the list.
210
+ */
211
+ onStartReachedThreshold?: ?number,
212
+ /**
213
+ * Called when the viewability of rows changes, as defined by the
214
+ * `viewabilityConfig` prop.
215
+ */
216
+ onViewableItemsChanged?: ?(info: {
217
+ viewableItems: Array<ViewToken>,
218
+ changed: Array<ViewToken>,
219
+ ...
220
+ }) => void,
221
+ persistentScrollbar?: ?boolean,
222
+ /**
223
+ * Set this when offset is needed for the loading indicator to show correctly.
224
+ */
225
+ progressViewOffset?: number,
226
+ /**
227
+ * A custom refresh control element. When set, it overrides the default
228
+ * <RefreshControl> component built internally. The onRefresh and refreshing
229
+ * props are also ignored. Only works for vertical VirtualizedList.
230
+ */
231
+ refreshControl?: ?React.Element<any>,
232
+ /**
233
+ * Set this true while waiting for new data from a refresh.
234
+ */
235
+ refreshing?: ?boolean,
236
+ /**
237
+ * Note: may have bugs (missing content) in some circumstances - use at your own risk.
238
+ *
239
+ * This may improve scroll performance for large lists.
240
+ */
241
+ removeClippedSubviews?: boolean,
242
+ /**
243
+ * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
244
+ */
245
+ renderScrollComponent?: (props: Object) => React.Element<any>,
246
+ /**
247
+ * Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
248
+ * screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
249
+ */
250
+ updateCellsBatchingPeriod?: ?number,
251
+ /**
252
+ * See `ViewabilityHelper` for flow type and further documentation.
253
+ */
254
+ viewabilityConfig?: ViewabilityConfig,
255
+ /**
256
+ * List of ViewabilityConfig/onViewableItemsChanged pairs. A specific onViewableItemsChanged
257
+ * will be called when its corresponding ViewabilityConfig's conditions are met.
258
+ */
259
+ viewabilityConfigCallbackPairs?: Array<ViewabilityConfigCallbackPair>,
260
+ /**
261
+ * Determines the maximum number of items rendered outside of the visible area, in units of
262
+ * visible lengths. So if your list fills the screen, then `windowSize={21}` (the default) will
263
+ * render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
264
+ * this number will reduce memory consumption and may improve performance, but will increase the
265
+ * chance that fast scrolling may reveal momentary blank areas of unrendered content.
266
+ */
267
+ windowSize?: ?number,
268
+ /**
269
+ * The legacy implementation is no longer supported.
270
+ */
271
+ legacyImplementation?: empty,
272
+ |};
273
+
274
+ export type Props = {|
275
+ ...React.ElementConfig<ScrollView>,
276
+ ...RequiredProps,
277
+ ...OptionalProps,
278
+ |};
279
+
280
+ /**
281
+ * Subset of properties needed to calculate frame metrics
282
+ */
283
+ export type FrameMetricProps = {
284
+ data: RequiredProps['data'],
285
+ getItemCount: RequiredProps['getItemCount'],
286
+ getItem: RequiredProps['getItem'],
287
+ getItemLayout?: OptionalProps['getItemLayout'],
288
+ keyExtractor?: OptionalProps['keyExtractor'],
289
+ ...
290
+ };