Skip to content

Commit 621969b

Browse files
NickGerlemanfacebook-github-bot
authored andcommittedDec 15, 2022
Add missing VirtualizedList Imperative Types
Summary: Adds some imperative VirtualizedList methods to the TS types which are documented on the website and are public enough. Also explicitly add `viewOffset` to `scrollToItem` since `scrollToItem` params are indefinite in flow and are passed to `scrollToIndex` (which supports the prop). Changelog: [General][Fixed] - Add missing VirtualizedList Imperative Types Reviewed By: GijsWeterings Differential Revision: D42047674 fbshipit-source-id: 60f7b35b049853d9fcb724918b3a0008a75ea573
·
v0.80.0latest
1 parent 8d6e2f8 commit 621969b

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed
 

‎Libraries/Lists/FlatList.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export class FlatList<ItemT = any> extends React.Component<
206206
scrollToItem: (params: {
207207
animated?: boolean | null | undefined;
208208
item: ItemT;
209+
viewOffset?: number | undefined;
209210
viewPosition?: number | undefined;
210211
}) => void;
211212

‎Libraries/Lists/FlatList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
334334
scrollToItem(params: {
335335
animated?: ?boolean,
336336
item: ItemT,
337+
viewOffset?: number,
337338
viewPosition?: number,
338339
...
339340
}) {

‎Libraries/Lists/VirtualizedList.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import type * as React from 'react';
1111
import type {LayoutChangeEvent} from '../../types';
1212
import {StyleProp} from '../StyleSheet/StyleSheet';
1313
import {ViewStyle} from '../StyleSheet/StyleSheetTypes';
14-
import type {ScrollViewProps} from '../Components/ScrollView/ScrollView';
14+
import type {
15+
ScrollResponderMixin,
16+
ScrollView,
17+
ScrollViewProps,
18+
} from '../Components/ScrollView/ScrollView';
19+
import type {View} from '../Components/View/View';
1520

1621
export interface ViewToken {
1722
item: any;
@@ -98,6 +103,7 @@ export class VirtualizedList<ItemT> extends React.Component<
98103
scrollToItem: (params: {
99104
animated?: boolean | undefined;
100105
item: ItemT;
106+
viewOffset?: number | undefined;
101107
viewPosition?: number | undefined;
102108
}) => void;
103109

@@ -113,6 +119,13 @@ export class VirtualizedList<ItemT> extends React.Component<
113119
}) => void;
114120

115121
recordInteraction: () => void;
122+
123+
getScrollRef: () =>
124+
| React.ElementRef<typeof ScrollView>
125+
| React.ElementRef<typeof View>
126+
| null;
127+
128+
getScrollResponder: () => ScrollResponderMixin | null;
116129
}
117130

118131
/**

‎Libraries/Lists/VirtualizedList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export default class VirtualizedList extends StateSafePureComponent<
263263
scrollToItem(params: {
264264
animated?: ?boolean,
265265
item: Item,
266+
viewOffset?: number,
266267
viewPosition?: number,
267268
...
268269
}) {

0 commit comments

Comments
 (0)
Please sign in to comment.