Skip to content

Commit

Permalink
Add missing VirtualizedList Imperative Types
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Dec 15, 2022
1 parent 8d6e2f8 commit 621969b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class FlatList<ItemT = any> extends React.Component<
scrollToItem: (params: {
animated?: boolean | null | undefined;
item: ItemT;
viewOffset?: number | undefined;
viewPosition?: number | undefined;
}) => void;

Expand Down
1 change: 1 addition & 0 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
scrollToItem(params: {
animated?: ?boolean,
item: ItemT,
viewOffset?: number,
viewPosition?: number,
...
}) {
Expand Down
15 changes: 14 additions & 1 deletion Libraries/Lists/VirtualizedList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import type * as React from 'react';
import type {LayoutChangeEvent} from '../../types';
import {StyleProp} from '../StyleSheet/StyleSheet';
import {ViewStyle} from '../StyleSheet/StyleSheetTypes';
import type {ScrollViewProps} from '../Components/ScrollView/ScrollView';
import type {
ScrollResponderMixin,
ScrollView,
ScrollViewProps,
} from '../Components/ScrollView/ScrollView';
import type {View} from '../Components/View/View';

export interface ViewToken {
item: any;
Expand Down Expand Up @@ -98,6 +103,7 @@ export class VirtualizedList<ItemT> extends React.Component<
scrollToItem: (params: {
animated?: boolean | undefined;
item: ItemT;
viewOffset?: number | undefined;
viewPosition?: number | undefined;
}) => void;

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

recordInteraction: () => void;

getScrollRef: () =>
| React.ElementRef<typeof ScrollView>
| React.ElementRef<typeof View>
| null;

getScrollResponder: () => ScrollResponderMixin | null;
}

/**
Expand Down
1 change: 1 addition & 0 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export default class VirtualizedList extends StateSafePureComponent<
scrollToItem(params: {
animated?: ?boolean,
item: Item,
viewOffset?: number,
viewPosition?: number,
...
}) {
Expand Down

0 comments on commit 621969b

Please sign in to comment.