Adding $FlowFixMe to invalid prop accesses

Reviewed By: yungsters

Differential Revision: D7977387

fbshipit-source-id: 442e7445be62f78bdf166a2b97ef031e39877355
This commit is contained in:
Eli White 2018-05-12 10:25:08 -07:00 committed by Facebook Github Bot
parent 7ba7acdee7
commit f19ee28e7d
12 changed files with 55 additions and 0 deletions

View File

@ -636,6 +636,7 @@ const ScrollView = createReactClass({
}, },
_getKeyForIndex: function(index, childArray) { _getKeyForIndex: function(index, childArray) {
// $FlowFixMe Invalid prop usage
const child = childArray[index]; const child = childArray[index];
return child && child.key; return child && child.key;
}, },
@ -668,6 +669,7 @@ const ScrollView = createReactClass({
if (!this.props.stickyHeaderIndices) { if (!this.props.stickyHeaderIndices) {
return; return;
} }
// $FlowFixMe Invalid prop usage
const childArray = React.Children.toArray(this.props.children); const childArray = React.Children.toArray(this.props.children);
if (key !== this._getKeyForIndex(index, childArray)) { if (key !== this._getKeyForIndex(index, childArray)) {
// ignore stale layout update // ignore stale layout update
@ -677,8 +679,10 @@ const ScrollView = createReactClass({
const layoutY = event.nativeEvent.layout.y; const layoutY = event.nativeEvent.layout.y;
this._headerLayoutYs.set(key, layoutY); this._headerLayoutYs.set(key, layoutY);
// $FlowFixMe Invalid prop usage
const indexOfIndex = this.props.stickyHeaderIndices.indexOf(index); const indexOfIndex = this.props.stickyHeaderIndices.indexOf(index);
const previousHeaderIndex = this.props.stickyHeaderIndices[ const previousHeaderIndex = this.props.stickyHeaderIndices[
// $FlowFixMe Invalid prop usage
indexOfIndex - 1 indexOfIndex - 1
]; ];
if (previousHeaderIndex != null) { if (previousHeaderIndex != null) {
@ -799,12 +803,16 @@ const ScrollView = createReactClass({
const hasStickyHeaders = const hasStickyHeaders =
stickyHeaderIndices && stickyHeaderIndices.length > 0; stickyHeaderIndices && stickyHeaderIndices.length > 0;
const childArray = const childArray =
// $FlowFixMe Invalid prop usage
hasStickyHeaders && React.Children.toArray(this.props.children); hasStickyHeaders && React.Children.toArray(this.props.children);
const children = hasStickyHeaders const children = hasStickyHeaders
// $FlowFixMe Invalid prop usage
? childArray.map((child, index) => { ? childArray.map((child, index) => {
// $FlowFixMe Invalid prop usage
const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1; const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1;
if (indexOfIndex > -1) { if (indexOfIndex > -1) {
const key = child.key; const key = child.key;
// $FlowFixMe Invalid prop usage
const nextIndex = stickyHeaderIndices[indexOfIndex + 1]; const nextIndex = stickyHeaderIndices[indexOfIndex + 1];
return ( return (
<ScrollViewStickyHeader <ScrollViewStickyHeader
@ -826,10 +834,12 @@ const ScrollView = createReactClass({
return child; return child;
} }
}) })
// $FlowFixMe Invalid prop usage
: this.props.children; : this.props.children;
const contentContainer = ( const contentContainer = (
<ScrollContentContainerViewClass <ScrollContentContainerViewClass
{...contentSizeChangeProps} {...contentSizeChangeProps}
// $FlowFixMe Invalid prop usage
ref={this._setInnerViewRef} ref={this._setInnerViewRef}
style={contentContainerStyle} style={contentContainerStyle}
removeClippedSubviews={ removeClippedSubviews={
@ -913,6 +923,7 @@ const ScrollView = createReactClass({
// On iOS the RefreshControl is a child of the ScrollView. // On iOS the RefreshControl is a child of the ScrollView.
// tvOS lacks native support for RefreshControl, so don't include it in that case // tvOS lacks native support for RefreshControl, so don't include it in that case
return ( return (
// $FlowFixMe Invalid prop usage
<ScrollViewClass {...props} ref={this._setScrollViewRef}> <ScrollViewClass {...props} ref={this._setScrollViewRef}>
{Platform.isTVOS ? null : refreshControl} {Platform.isTVOS ? null : refreshControl}
{contentContainer} {contentContainer}
@ -931,6 +942,7 @@ const ScrollView = createReactClass({
<ScrollViewClass <ScrollViewClass
{...props} {...props}
style={baseStyle} style={baseStyle}
// $FlowFixMe Invalid prop usage
ref={this._setScrollViewRef}> ref={this._setScrollViewRef}>
{contentContainer} {contentContainer}
</ScrollViewClass>, </ScrollViewClass>,
@ -938,6 +950,7 @@ const ScrollView = createReactClass({
} }
} }
return ( return (
// $FlowFixMe Invalid prop usage
<ScrollViewClass {...props} ref={this._setScrollViewRef}> <ScrollViewClass {...props} ref={this._setScrollViewRef}>
{contentContainer} {contentContainer}
</ScrollViewClass> </ScrollViewClass>

View File

@ -1040,6 +1040,7 @@ const TextInput = createReactClass({
}, },
_onTextInput: function(event: Event) { _onTextInput: function(event: Event) {
// $FlowFixMe Invalid prop usage
this.props.onTextInput && this.props.onTextInput(event); this.props.onTextInput && this.props.onTextInput(event);
}, },

View File

@ -138,6 +138,7 @@ const TouchableBounce = createReactClass({
}, },
touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET { touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET {
// $FlowFixMe Invalid prop usage
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
}, },

View File

@ -190,6 +190,7 @@ const TouchableHighlight = createReactClass({
getDefaultProps: () => DEFAULT_PROPS, getDefaultProps: () => DEFAULT_PROPS,
getInitialState: function() { getInitialState: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = false; this._isMounted = false;
if (this.props.testOnly_pressed) { if (this.props.testOnly_pressed) {
return { return {
@ -211,11 +212,13 @@ const TouchableHighlight = createReactClass({
}, },
componentDidMount: function() { componentDidMount: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = true; this._isMounted = true;
ensurePositiveDelayProps(this.props); ensurePositiveDelayProps(this.props);
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = false; this._isMounted = false;
clearTimeout(this._hideTimeout); clearTimeout(this._hideTimeout);
}, },
@ -235,12 +238,14 @@ const TouchableHighlight = createReactClass({
*/ */
touchableHandleActivePressIn: function(e: PressEvent) { touchableHandleActivePressIn: function(e: PressEvent) {
clearTimeout(this._hideTimeout); clearTimeout(this._hideTimeout);
// $FlowFixMe Invalid prop usage
this._hideTimeout = null; this._hideTimeout = null;
this._showUnderlay(); this._showUnderlay();
this.props.onPressIn && this.props.onPressIn(e); this.props.onPressIn && this.props.onPressIn(e);
}, },
touchableHandleActivePressOut: function(e: PressEvent) { touchableHandleActivePressOut: function(e: PressEvent) {
// $FlowFixMe Invalid prop usage
if (!this._hideTimeout) { if (!this._hideTimeout) {
this._hideUnderlay(); this._hideUnderlay();
} }
@ -251,6 +256,7 @@ const TouchableHighlight = createReactClass({
clearTimeout(this._hideTimeout); clearTimeout(this._hideTimeout);
if (!Platform.isTVOS) { if (!Platform.isTVOS) {
this._showUnderlay(); this._showUnderlay();
// $FlowFixMe Invalid prop usage
this._hideTimeout = setTimeout( this._hideTimeout = setTimeout(
this._hideUnderlay, this._hideUnderlay,
this.props.delayPressOut, this.props.delayPressOut,
@ -284,6 +290,7 @@ const TouchableHighlight = createReactClass({
}, },
_showUnderlay: function() { _showUnderlay: function() {
// $FlowFixMe Invalid prop usage
if (!this._isMounted || !this._hasPressHandler()) { if (!this._isMounted || !this._hasPressHandler()) {
return; return;
} }
@ -300,6 +307,7 @@ const TouchableHighlight = createReactClass({
_hideUnderlay: function() { _hideUnderlay: function() {
clearTimeout(this._hideTimeout); clearTimeout(this._hideTimeout);
// $FlowFixMe Invalid prop usage
this._hideTimeout = null; this._hideTimeout = null;
if (this.props.testOnly_pressed) { if (this.props.testOnly_pressed) {
return; return;
@ -323,10 +331,12 @@ const TouchableHighlight = createReactClass({
}, },
render: function() { render: function() {
// $FlowFixMe Invalid prop usage
const child = React.Children.only(this.props.children); const child = React.Children.only(this.props.children);
return ( return (
<View <View
accessible={this.props.accessible !== false} accessible={this.props.accessible !== false}
// $FlowFixMe Invalid prop usage
accessibilityLabel={this.props.accessibilityLabel} accessibilityLabel={this.props.accessibilityLabel}
accessibilityComponentType={this.props.accessibilityComponentType} accessibilityComponentType={this.props.accessibilityComponentType}
accessibilityTraits={this.props.accessibilityTraits} accessibilityTraits={this.props.accessibilityTraits}
@ -347,7 +357,9 @@ const TouchableHighlight = createReactClass({
onResponderMove={this.touchableHandleResponderMove} onResponderMove={this.touchableHandleResponderMove}
onResponderRelease={this.touchableHandleResponderRelease} onResponderRelease={this.touchableHandleResponderRelease}
onResponderTerminate={this.touchableHandleResponderTerminate} onResponderTerminate={this.touchableHandleResponderTerminate}
// $FlowFixMe Invalid prop usage
nativeID={this.props.nativeID} nativeID={this.props.nativeID}
// $FlowFixMe Invalid prop usage
testID={this.props.testID}> testID={this.props.testID}>
{React.cloneElement(child, { {React.cloneElement(child, {
style: StyleSheet.compose( style: StyleSheet.compose(

View File

@ -144,6 +144,7 @@ const TouchableWithoutFeedback = createReactClass({
}, },
touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET { touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET {
// $FlowFixMe Invalid prop usage
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
}, },
@ -194,10 +195,13 @@ const TouchableWithoutFeedback = createReactClass({
: child.props.style; : child.props.style;
return (React: any).cloneElement(child, { return (React: any).cloneElement(child, {
accessible: this.props.accessible !== false, accessible: this.props.accessible !== false,
// $FlowFixMe Invalid prop usage
accessibilityLabel: this.props.accessibilityLabel, accessibilityLabel: this.props.accessibilityLabel,
accessibilityComponentType: this.props.accessibilityComponentType, accessibilityComponentType: this.props.accessibilityComponentType,
accessibilityTraits: this.props.accessibilityTraits, accessibilityTraits: this.props.accessibilityTraits,
// $FlowFixMe Invalid prop usage
nativeID: this.props.nativeID, nativeID: this.props.nativeID,
// $FlowFixMe Invalid prop usage
testID: this.props.testID, testID: this.props.testID,
onLayout: this.props.onLayout, onLayout: this.props.onLayout,
hitSlop: this.props.hitSlop, hitSlop: this.props.hitSlop,

View File

@ -117,9 +117,11 @@ class SwipeableListView extends React.Component<Props, State> {
render(): React.Node { render(): React.Node {
return ( return (
// $FlowFixMe Invalid prop usage
<ListView <ListView
{...this.props} {...this.props}
ref={ref => { ref={ref => {
// $FlowFixMe Invalid prop usage
this._listViewRef = ref; this._listViewRef = ref;
}} }}
dataSource={this.state.dataSource.getDataSource()} dataSource={this.state.dataSource.getDataSource()}

View File

@ -476,6 +476,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = []; _virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];
_captureRef = ref => { _captureRef = ref => {
// $FlowFixMe Invalid prop usage
this._listRef = ref; this._listRef = ref;
}; };

View File

@ -516,8 +516,10 @@ const ListView = createReactClass({
if (props.removeClippedSubviews === undefined) { if (props.removeClippedSubviews === undefined) {
props.removeClippedSubviews = true; props.removeClippedSubviews = true;
} }
// $FlowFixMe Invalid prop usage
Object.assign(props, { Object.assign(props, {
onScroll: this._onScroll, onScroll: this._onScroll,
// $FlowFixMe Invalid prop usage
stickyHeaderIndices: this.props.stickyHeaderIndices.concat( stickyHeaderIndices: this.props.stickyHeaderIndices.concat(
stickySectionHeaderIndices, stickySectionHeaderIndices,
), ),

View File

@ -85,6 +85,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
} }
scrollToOffset(params: {animated?: ?boolean, offset: number}) { scrollToOffset(params: {animated?: ?boolean, offset: number}) {
const {animated, offset} = params; const {animated, offset} = params;
// $FlowFixMe Invalid prop usage
this._listRef.scrollTo( this._listRef.scrollTo(
this.props.horizontal ? {x: offset, animated} : {y: offset, animated}, this.props.horizontal ? {x: offset, animated} : {y: offset, animated},
); );
@ -94,6 +95,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
} }
setNativeProps(props: Object) { setNativeProps(props: Object) {
if (this._listRef) { if (this._listRef) {
// $FlowFixMe Invalid prop usage
this._listRef.setNativeProps(props); this._listRef.setNativeProps(props);
} }
} }
@ -102,6 +104,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
renderScrollComponent: (props: Props) => { renderScrollComponent: (props: Props) => {
if (props.onRefresh) { if (props.onRefresh) {
return ( return (
// $FlowFixMe Invalid prop usage
<ScrollView <ScrollView
{...props} {...props}
refreshControl={ refreshControl={
@ -117,6 +120,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
/> />
); );
} else { } else {
// $FlowFixMe Invalid prop usage
return <ScrollView {...props} />; return <ScrollView {...props} />;
} }
}, },
@ -135,6 +139,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
} }
render() { render() {
return ( return (
// $FlowFixMe Invalid prop usage
<ListView <ListView
{...this.props} {...this.props}
dataSource={this.state.ds} dataSource={this.state.ds}
@ -142,6 +147,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
renderRow={this._renderRow} renderRow={this._renderRow}
renderFooter={this.props.FooterComponent && this._renderFooter} renderFooter={this.props.FooterComponent && this._renderFooter}
renderSectionHeader={this.props.sections && this._renderSectionHeader} renderSectionHeader={this.props.sections && this._renderSectionHeader}
// $FlowFixMe Invalid prop usage
renderSeparator={this.props.SeparatorComponent && this._renderSeparator} renderSeparator={this.props.SeparatorComponent && this._renderSeparator}
/> />
); );
@ -167,6 +173,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
} else { } else {
invariant(!props.sections, 'Cannot have both sections and items props.'); invariant(!props.sections, 'Cannot have both sections and items props.');
return { return {
// $FlowFixMe Invalid prop usage
ds: state.ds.cloneWithRows(props.items), ds: state.ds.cloneWithRows(props.items),
sectionHeaderData, sectionHeaderData,
}; };

View File

@ -284,6 +284,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
*/ */
recordInteraction() { recordInteraction() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
// $FlowFixMe Invalid prop usage
listRef && listRef.recordInteraction(); listRef && listRef.recordInteraction();
} }
@ -294,6 +295,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
*/ */
flashScrollIndicators() { flashScrollIndicators() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
// $FlowFixMe Invalid prop usage
listRef && listRef.flashScrollIndicators(); listRef && listRef.flashScrollIndicators();
} }
@ -303,6 +305,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
getScrollResponder(): ?ScrollView { getScrollResponder(): ?ScrollView {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) { if (listRef) {
// $FlowFixMe Invalid prop usage
return listRef.getScrollResponder(); return listRef.getScrollResponder();
} }
} }
@ -310,6 +313,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
getScrollableNode() { getScrollableNode() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) { if (listRef) {
// $FlowFixMe Invalid prop usage
return listRef.getScrollableNode(); return listRef.getScrollableNode();
} }
} }
@ -317,6 +321,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
setNativeProps(props: Object) { setNativeProps(props: Object) {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) { if (listRef) {
// $FlowFixMe Invalid prop usage
listRef.setNativeProps(props); listRef.setNativeProps(props);
} }
} }

View File

@ -924,6 +924,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
(this.props.renderScrollComponent || this._defaultRenderScrollComponent)( (this.props.renderScrollComponent || this._defaultRenderScrollComponent)(
scrollProps, scrollProps,
), ),
// $FlowFixMe Invalid prop usage
{ {
ref: this._captureScrollRef, ref: this._captureScrollRef,
}, },
@ -1016,6 +1017,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
'`', '`',
); );
return ( return (
// $FlowFixMe Invalid prop usage
<ScrollView <ScrollView
{...props} {...props}
refreshControl={ refreshControl={
@ -1032,6 +1034,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
/> />
); );
} else { } else {
// $FlowFixMe Invalid prop usage
return <ScrollView {...props} />; return <ScrollView {...props} />;
} }
}; };

View File

@ -39,6 +39,7 @@ exports.examples = [
<View> <View>
<ScrollView <ScrollView
ref={scrollView => { ref={scrollView => {
// $FlowFixMe Invalid prop usage
_scrollView = scrollView; _scrollView = scrollView;
}} }}
automaticallyAdjustContentInsets={false} automaticallyAdjustContentInsets={false}
@ -96,18 +97,21 @@ exports.examples = [
<Button <Button
label="Scroll to start" label="Scroll to start"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.scrollTo({x: 0}); _scrollView.scrollTo({x: 0});
}} }}
/> />
<Button <Button
label="Scroll to end" label="Scroll to end"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.scrollToEnd({animated: true}); _scrollView.scrollToEnd({animated: true});
}} }}
/> />
<Button <Button
label="Flash scroll indicators" label="Flash scroll indicators"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.flashScrollIndicators(); _scrollView.flashScrollIndicators();
}} }}
/> />