mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add missing class annotations and lock xplat/js
Reviewed By: SamChou19815 Differential Revision: D38374141 fbshipit-source-id: 967291a5c1a29f39b7272726c8b41bc74d1be043
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c687dd3a77
commit
0ccbe5f704
@@ -433,6 +433,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
}
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
componentDidUpdate(prevProps: Props<ItemT>) {
|
||||
invariant(
|
||||
prevProps.numColumns === this.props.numColumns,
|
||||
@@ -463,6 +464,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
this._listRef = ref;
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_checkProps(props: Props<ItemT>) {
|
||||
const {
|
||||
// $FlowFixMe[prop-missing] this prop doesn't exist, is only used for an invariant
|
||||
@@ -494,6 +496,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getItem = (data: Array<ItemT>, index: number) => {
|
||||
const numColumns = numColumnsOrDefault(this.props.numColumns);
|
||||
if (numColumns > 1) {
|
||||
@@ -520,6 +523,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
}
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_keyExtractor = (items: ItemT | Array<ItemT>, index: number) => {
|
||||
const numColumns = numColumnsOrDefault(this.props.numColumns);
|
||||
const keyExtractor = this.props.keyExtractor ?? defaultKeyExtractor;
|
||||
@@ -561,6 +565,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
changed: Array<ViewToken>,
|
||||
...
|
||||
}) => void,
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) {
|
||||
return (info: {
|
||||
viewableItems: Array<ViewToken>,
|
||||
@@ -590,6 +595,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
columnWrapperStyle: ?ViewStyleProp,
|
||||
numColumns: ?number,
|
||||
extraData: ?any,
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) => {
|
||||
const cols = numColumnsOrDefault(numColumns);
|
||||
|
||||
@@ -651,6 +657,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
};
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_memoizedRenderer = memoizeOne(this._renderer);
|
||||
|
||||
render(): React.Node {
|
||||
|
||||
@@ -182,7 +182,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
viewOffset?: number,
|
||||
viewPosition?: number,
|
||||
...
|
||||
}) {
|
||||
}): $FlowFixMe {
|
||||
const {
|
||||
data,
|
||||
horizontal,
|
||||
@@ -369,6 +369,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getScrollMetrics = () => {
|
||||
return this._scrollMetrics;
|
||||
};
|
||||
@@ -377,6 +378,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
return this._hasMore;
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getOutermostParentListRef = () => {
|
||||
if (this._isNestedWithSameOrientation()) {
|
||||
return this.context.getOutermostParentListRef();
|
||||
@@ -631,6 +633,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
_getSpacerKey = (isVertical: boolean): string =>
|
||||
isVertical ? 'height' : 'width';
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_keyExtractor(item: Item, index: number) {
|
||||
if (this.props.keyExtractor != null) {
|
||||
return this.props.keyExtractor(item, index);
|
||||
@@ -985,6 +988,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
> = new Map();
|
||||
_offsetFromParentVirtualizedList: number = 0;
|
||||
_prevParentOffset: number = 0;
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_scrollMetrics = {
|
||||
contentLength: 0,
|
||||
dOffset: 0,
|
||||
@@ -1016,6 +1020,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getCellsInItemCount = (props: Props) => {
|
||||
const {getCellsInItemCount, data} = props;
|
||||
if (getCellsInItemCount) {
|
||||
@@ -1231,6 +1236,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
this._headerLength = this._selectLength(e.nativeEvent.layout);
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_renderDebugOverlay() {
|
||||
const normalize =
|
||||
this._scrollMetrics.visibleLength /
|
||||
@@ -1376,7 +1382,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
visibleLength: number,
|
||||
offset: number,
|
||||
...
|
||||
}) => {
|
||||
}): $FlowFixMe => {
|
||||
// Offset of the top of the nested list relative to the top of its parent's viewport
|
||||
const offset = metrics.offset - this._offsetFromParentVirtualizedList;
|
||||
// Child's visible length is the same as its parent's
|
||||
@@ -1653,6 +1659,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
});
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_createViewToken = (index: number, isViewable: boolean) => {
|
||||
const {data, getItem} = this.props;
|
||||
const item = getItem(data, index);
|
||||
@@ -1770,6 +1777,7 @@ class CellRenderer extends React.Component<
|
||||
CellRendererProps,
|
||||
CellRendererState,
|
||||
> {
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
state = {
|
||||
separatorProps: {
|
||||
highlighted: false,
|
||||
@@ -1791,6 +1799,7 @@ class CellRenderer extends React.Component<
|
||||
|
||||
// TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
|
||||
// reused by SectionList and we can keep VirtualizedList simpler.
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_separators = {
|
||||
highlight: () => {
|
||||
const {cellKey, prevCellKey} = this.props;
|
||||
@@ -1837,6 +1846,7 @@ class CellRenderer extends React.Component<
|
||||
ListItemComponent: any,
|
||||
item: any,
|
||||
index: any,
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) {
|
||||
if (renderItem && ListItemComponent) {
|
||||
console.warn(
|
||||
@@ -1882,6 +1892,7 @@ class CellRenderer extends React.Component<
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
render() {
|
||||
const {
|
||||
CellRendererComponent,
|
||||
|
||||
@@ -202,7 +202,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
viewOffset?: number,
|
||||
viewPosition?: number,
|
||||
...
|
||||
}) {
|
||||
}): $FlowFixMe {
|
||||
const {
|
||||
data,
|
||||
horizontal,
|
||||
@@ -389,6 +389,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getScrollMetrics = () => {
|
||||
return this._scrollMetrics;
|
||||
};
|
||||
@@ -397,6 +398,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
return this._hasMore;
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getOutermostParentListRef = () => {
|
||||
if (this._isNestedWithSameOrientation()) {
|
||||
return this.context.getOutermostParentListRef();
|
||||
@@ -849,6 +851,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
keyExtractor?: ?(item: Item, index: number) => string,
|
||||
...
|
||||
},
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) {
|
||||
if (props.keyExtractor != null) {
|
||||
return props.keyExtractor(item, index);
|
||||
@@ -1180,6 +1183,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
> = new Map();
|
||||
_offsetFromParentVirtualizedList: number = 0;
|
||||
_prevParentOffset: number = 0;
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_scrollMetrics = {
|
||||
contentLength: 0,
|
||||
dOffset: 0,
|
||||
@@ -1211,6 +1215,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getCellsInItemCount = (props: Props) => {
|
||||
const {getCellsInItemCount, data} = props;
|
||||
if (getCellsInItemCount) {
|
||||
@@ -1442,6 +1447,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
this._headerLength = this._selectLength(e.nativeEvent.layout);
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_renderDebugOverlay() {
|
||||
const normalize =
|
||||
this._scrollMetrics.visibleLength /
|
||||
@@ -1593,7 +1599,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
visibleLength: number,
|
||||
offset: number,
|
||||
...
|
||||
}) => {
|
||||
}): $FlowFixMe => {
|
||||
// Offset of the top of the nested list relative to the top of its parent's viewport
|
||||
const offset = metrics.offset - this._offsetFromParentVirtualizedList;
|
||||
// Child's visible length is the same as its parent's
|
||||
@@ -1797,6 +1803,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
index: number,
|
||||
isViewable: boolean,
|
||||
props: FrameMetricProps,
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) => {
|
||||
const {data, getItem} = props;
|
||||
const item = getItem(data, index);
|
||||
@@ -1986,6 +1993,7 @@ class CellRenderer extends React.Component<
|
||||
CellRendererProps,
|
||||
CellRendererState,
|
||||
> {
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
state = {
|
||||
separatorProps: {
|
||||
highlighted: false,
|
||||
@@ -2007,6 +2015,7 @@ class CellRenderer extends React.Component<
|
||||
|
||||
// TODO: consider factoring separator stuff out of VirtualizedList into FlatList since it's not
|
||||
// reused by SectionList and we can keep VirtualizedList simpler.
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_separators = {
|
||||
highlight: () => {
|
||||
const {cellKey, prevCellKey} = this.props;
|
||||
@@ -2053,6 +2062,7 @@ class CellRenderer extends React.Component<
|
||||
ListItemComponent: any,
|
||||
item: any,
|
||||
index: any,
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
) {
|
||||
if (renderItem && ListItemComponent) {
|
||||
console.warn(
|
||||
@@ -2098,6 +2108,7 @@ class CellRenderer extends React.Component<
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
render() {
|
||||
const {
|
||||
CellRendererComponent,
|
||||
|
||||
@@ -237,6 +237,7 @@ class VirtualizedSectionList<
|
||||
return null;
|
||||
}
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_keyExtractor = (item: Item, index: number) => {
|
||||
const info = this._subExtractor(index);
|
||||
return (info && info.key) || String(index);
|
||||
@@ -340,7 +341,7 @@ class VirtualizedSectionList<
|
||||
};
|
||||
|
||||
_renderItem =
|
||||
(listItemCount: number) =>
|
||||
(listItemCount: number): $FlowFixMe =>
|
||||
// eslint-disable-next-line react/no-unstable-nested-components
|
||||
({
|
||||
item,
|
||||
|
||||
@@ -97,11 +97,14 @@ class FlatListExample extends React.PureComponent<Props, State> {
|
||||
this._listRef.scrollToIndex({viewPosition: 0.5, index: Number(text)});
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_scrollPos = new Animated.Value(0);
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_scrollSinkX = Animated.event(
|
||||
[{nativeEvent: {contentOffset: {x: this._scrollPos}}}],
|
||||
{useNativeDriver: true},
|
||||
);
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_scrollSinkY = Animated.event(
|
||||
[{nativeEvent: {contentOffset: {y: this._scrollPos}}}],
|
||||
{useNativeDriver: true},
|
||||
@@ -271,6 +274,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
|
||||
) => {
|
||||
this._listRef = ref;
|
||||
};
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_getItemLayout = (data: any, index: number) => {
|
||||
return getItemLayout(data, index, this.state.horizontal);
|
||||
};
|
||||
@@ -282,13 +286,16 @@ class FlatListExample extends React.PureComponent<Props, State> {
|
||||
data: state.data.concat(genItemData(100, state.data.length)),
|
||||
}));
|
||||
};
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_onPressCallback = () => {
|
||||
const {onPressDisabled} = this.state;
|
||||
const warning = () => console.log('onPress disabled');
|
||||
const onPressAction = onPressDisabled ? warning : this._pressItem;
|
||||
return onPressAction;
|
||||
};
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_onRefresh = () => Alert.alert('onRefresh: nothing to refresh :P');
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
_renderItemComponent = () => {
|
||||
const flatListPropKey = this.state.useFlatListItemComponent
|
||||
? 'ListItemComponent'
|
||||
|
||||
@@ -152,7 +152,7 @@ class MultiColumnExample extends React.PureComponent<
|
||||
item: Item,
|
||||
accessibilityCollectionItem: AccessibilityCollectionItem,
|
||||
...
|
||||
}) => {
|
||||
}): $FlowFixMe => {
|
||||
return (
|
||||
<View
|
||||
importantForAccessibility="yes"
|
||||
|
||||
Reference in New Issue
Block a user