mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Fix $FlowFixMe in Flatlist
Summary: $FlowFixMe suppressed type validation on _listRef. Add appropriate typing to let Flow succeed when $FlowFixMe is removed. Not sure what this project's philosophy around ref types is. In some places I've seen them annotated as any rather than trying to get a more granular type to match. I'm open to suggestions. `yarn flow` [INTERNAL] [ENHANCEMENT] [FlatList.js] - Remove $FlowFixMe from FlatList Closes https://github.com/facebook/react-native/pull/16882 Differential Revision: D6386479 Pulled By: hramos fbshipit-source-id: bed14f2c7071525cb46425ab14214771de0277f3
This commit is contained in:
parent
ad4b124aa1
commit
22a1419900
@ -16,6 +16,7 @@ const MetroListView = require('MetroListView'); // Used as a fallback legacy opt
|
||||
const React = require('React');
|
||||
const View = require('View');
|
||||
const VirtualizedList = require('VirtualizedList');
|
||||
const ListView = require('ListView');
|
||||
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
@ -326,8 +327,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
* Scrolls to the end of the content. May be janky without `getItemLayout` prop.
|
||||
*/
|
||||
scrollToEnd(params?: ?{animated?: ?boolean}) {
|
||||
if (this._listRef) {
|
||||
this._listRef.scrollToEnd(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to the item at the specified index such that it is positioned in the viewable area
|
||||
@ -343,8 +346,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
viewOffset?: number,
|
||||
viewPosition?: number,
|
||||
}) {
|
||||
if (this._listRef) {
|
||||
this._listRef.scrollToIndex(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires linear scan through data - use `scrollToIndex` instead if possible.
|
||||
@ -357,8 +362,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
item: ItemT,
|
||||
viewPosition?: number,
|
||||
}) {
|
||||
if (this._listRef) {
|
||||
this._listRef.scrollToItem(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll to a specific content pixel offset in the list.
|
||||
@ -366,8 +373,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
* Check out [scrollToOffset](docs/virtualizedlist.html#scrolltooffset) of VirtualizedList
|
||||
*/
|
||||
scrollToOffset(params: {animated?: ?boolean, offset: number}) {
|
||||
if (this._listRef) {
|
||||
this._listRef.scrollToOffset(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the list an interaction has occurred, which should trigger viewability calculations, e.g.
|
||||
@ -375,8 +384,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
* taps on items or by navigation actions.
|
||||
*/
|
||||
recordInteraction() {
|
||||
if (this._listRef) {
|
||||
this._listRef.recordInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the scroll indicators momentarily.
|
||||
@ -384,8 +395,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
* @platform ios
|
||||
*/
|
||||
flashScrollIndicators() {
|
||||
if (this._listRef) {
|
||||
this._listRef.flashScrollIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a handle to the underlying scroll responder.
|
||||
@ -457,13 +470,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
}
|
||||
|
||||
_hasWarnedLegacy = false;
|
||||
_listRef: VirtualizedList;
|
||||
_listRef: null | VirtualizedList | ListView;
|
||||
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];
|
||||
|
||||
_captureRef = ref => {
|
||||
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
|
||||
* suppresses an error when upgrading Flow's support for React. To see the
|
||||
* error delete this comment and run Flow. */
|
||||
this._listRef = ref;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user