Permalink
Browse files

Adding $FlowFixMe to invalid prop accesses

Reviewed By: yungsters

Differential Revision: D7977387

fbshipit-source-id: 442e7445be62f78bdf166a2b97ef031e39877355
  • Loading branch information...
TheSavior authored and facebook-github-bot committed May 12, 2018
1 parent 7ba7acd commit f19ee28e7d896aaacf26c6f850230019bdef0d3d
@@ -636,6 +636,7 @@ const ScrollView = createReactClass({
},
_getKeyForIndex: function(index, childArray) {
// $FlowFixMe Invalid prop usage
const child = childArray[index];
return child && child.key;
},
@@ -668,6 +669,7 @@ const ScrollView = createReactClass({
if (!this.props.stickyHeaderIndices) {
return;
}
// $FlowFixMe Invalid prop usage
const childArray = React.Children.toArray(this.props.children);
if (key !== this._getKeyForIndex(index, childArray)) {
// ignore stale layout update
@@ -677,8 +679,10 @@ const ScrollView = createReactClass({
const layoutY = event.nativeEvent.layout.y;
this._headerLayoutYs.set(key, layoutY);
// $FlowFixMe Invalid prop usage
const indexOfIndex = this.props.stickyHeaderIndices.indexOf(index);
const previousHeaderIndex = this.props.stickyHeaderIndices[
// $FlowFixMe Invalid prop usage
indexOfIndex - 1
];
if (previousHeaderIndex != null) {
@@ -799,12 +803,16 @@ const ScrollView = createReactClass({
const hasStickyHeaders =
stickyHeaderIndices && stickyHeaderIndices.length > 0;
const childArray =
// $FlowFixMe Invalid prop usage
hasStickyHeaders && React.Children.toArray(this.props.children);
const children = hasStickyHeaders
// $FlowFixMe Invalid prop usage
? childArray.map((child, index) => {
// $FlowFixMe Invalid prop usage
const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1;
if (indexOfIndex > -1) {
const key = child.key;
// $FlowFixMe Invalid prop usage
const nextIndex = stickyHeaderIndices[indexOfIndex + 1];
return (
<ScrollViewStickyHeader
@@ -826,10 +834,12 @@ const ScrollView = createReactClass({
return child;
}
})
// $FlowFixMe Invalid prop usage
: this.props.children;
const contentContainer = (
<ScrollContentContainerViewClass
{...contentSizeChangeProps}
// $FlowFixMe Invalid prop usage
ref={this._setInnerViewRef}
style={contentContainerStyle}
removeClippedSubviews={
@@ -913,6 +923,7 @@ const ScrollView = createReactClass({
// On iOS the RefreshControl is a child of the ScrollView.
// tvOS lacks native support for RefreshControl, so don't include it in that case
return (
// $FlowFixMe Invalid prop usage
<ScrollViewClass {...props} ref={this._setScrollViewRef}>
{Platform.isTVOS ? null : refreshControl}
{contentContainer}
@@ -931,13 +942,15 @@ const ScrollView = createReactClass({
<ScrollViewClass
{...props}
style={baseStyle}
// $FlowFixMe Invalid prop usage
ref={this._setScrollViewRef}>
{contentContainer}
</ScrollViewClass>,
);
}
}
return (
// $FlowFixMe Invalid prop usage
<ScrollViewClass {...props} ref={this._setScrollViewRef}>
{contentContainer}
</ScrollViewClass>
@@ -1040,6 +1040,7 @@ const TextInput = createReactClass({
},
_onTextInput: function(event: Event) {
// $FlowFixMe Invalid prop usage
this.props.onTextInput && this.props.onTextInput(event);
},
@@ -138,6 +138,7 @@ const TouchableBounce = createReactClass({
},
touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET {
// $FlowFixMe Invalid prop usage
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
},
@@ -190,6 +190,7 @@ const TouchableHighlight = createReactClass({
getDefaultProps: () => DEFAULT_PROPS,
getInitialState: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = false;
if (this.props.testOnly_pressed) {
return {
@@ -211,11 +212,13 @@ const TouchableHighlight = createReactClass({
},
componentDidMount: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = true;
ensurePositiveDelayProps(this.props);
},
componentWillUnmount: function() {
// $FlowFixMe Invalid prop usage
this._isMounted = false;
clearTimeout(this._hideTimeout);
},
@@ -235,12 +238,14 @@ const TouchableHighlight = createReactClass({
*/
touchableHandleActivePressIn: function(e: PressEvent) {
clearTimeout(this._hideTimeout);
// $FlowFixMe Invalid prop usage
this._hideTimeout = null;
this._showUnderlay();
this.props.onPressIn && this.props.onPressIn(e);
},
touchableHandleActivePressOut: function(e: PressEvent) {
// $FlowFixMe Invalid prop usage
if (!this._hideTimeout) {
this._hideUnderlay();
}
@@ -251,6 +256,7 @@ const TouchableHighlight = createReactClass({
clearTimeout(this._hideTimeout);
if (!Platform.isTVOS) {
this._showUnderlay();
// $FlowFixMe Invalid prop usage
this._hideTimeout = setTimeout(
this._hideUnderlay,
this.props.delayPressOut,
@@ -284,6 +290,7 @@ const TouchableHighlight = createReactClass({
},
_showUnderlay: function() {
// $FlowFixMe Invalid prop usage
if (!this._isMounted || !this._hasPressHandler()) {
return;
}
@@ -300,6 +307,7 @@ const TouchableHighlight = createReactClass({
_hideUnderlay: function() {
clearTimeout(this._hideTimeout);
// $FlowFixMe Invalid prop usage
this._hideTimeout = null;
if (this.props.testOnly_pressed) {
return;
@@ -323,10 +331,12 @@ const TouchableHighlight = createReactClass({
},
render: function() {
// $FlowFixMe Invalid prop usage
const child = React.Children.only(this.props.children);
return (
<View
accessible={this.props.accessible !== false}
// $FlowFixMe Invalid prop usage
accessibilityLabel={this.props.accessibilityLabel}
accessibilityComponentType={this.props.accessibilityComponentType}
accessibilityTraits={this.props.accessibilityTraits}
@@ -347,7 +357,9 @@ const TouchableHighlight = createReactClass({
onResponderMove={this.touchableHandleResponderMove}
onResponderRelease={this.touchableHandleResponderRelease}
onResponderTerminate={this.touchableHandleResponderTerminate}
// $FlowFixMe Invalid prop usage
nativeID={this.props.nativeID}
// $FlowFixMe Invalid prop usage
testID={this.props.testID}>
{React.cloneElement(child, {
style: StyleSheet.compose(
@@ -144,6 +144,7 @@ const TouchableWithoutFeedback = createReactClass({
},
touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET {
// $FlowFixMe Invalid prop usage
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
},
@@ -194,10 +195,13 @@ const TouchableWithoutFeedback = createReactClass({
: child.props.style;
return (React: any).cloneElement(child, {
accessible: this.props.accessible !== false,
// $FlowFixMe Invalid prop usage
accessibilityLabel: this.props.accessibilityLabel,
accessibilityComponentType: this.props.accessibilityComponentType,
accessibilityTraits: this.props.accessibilityTraits,
// $FlowFixMe Invalid prop usage
nativeID: this.props.nativeID,
// $FlowFixMe Invalid prop usage
testID: this.props.testID,
onLayout: this.props.onLayout,
hitSlop: this.props.hitSlop,
@@ -117,9 +117,11 @@ class SwipeableListView extends React.Component<Props, State> {
render(): React.Node {
return (
// $FlowFixMe Invalid prop usage
<ListView
{...this.props}
ref={ref => {
// $FlowFixMe Invalid prop usage
this._listViewRef = ref;
}}
dataSource={this.state.dataSource.getDataSource()}
@@ -476,6 +476,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];
_captureRef = ref => {
// $FlowFixMe Invalid prop usage
this._listRef = ref;
};
@@ -516,8 +516,10 @@ const ListView = createReactClass({
if (props.removeClippedSubviews === undefined) {
props.removeClippedSubviews = true;
}
// $FlowFixMe Invalid prop usage
Object.assign(props, {
onScroll: this._onScroll,
// $FlowFixMe Invalid prop usage
stickyHeaderIndices: this.props.stickyHeaderIndices.concat(
stickySectionHeaderIndices,
),
@@ -85,6 +85,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
}
scrollToOffset(params: {animated?: ?boolean, offset: number}) {
const {animated, offset} = params;
// $FlowFixMe Invalid prop usage
this._listRef.scrollTo(
this.props.horizontal ? {x: offset, animated} : {y: offset, animated},
);
@@ -94,6 +95,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
}
setNativeProps(props: Object) {
if (this._listRef) {
// $FlowFixMe Invalid prop usage
this._listRef.setNativeProps(props);
}
}
@@ -102,6 +104,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
renderScrollComponent: (props: Props) => {
if (props.onRefresh) {
return (
// $FlowFixMe Invalid prop usage
<ScrollView
{...props}
refreshControl={
@@ -117,6 +120,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
/>
);
} else {
// $FlowFixMe Invalid prop usage
return <ScrollView {...props} />;
}
},
@@ -135,13 +139,15 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
}
render() {
return (
// $FlowFixMe Invalid prop usage
<ListView
{...this.props}
dataSource={this.state.ds}
ref={this._captureRef}
renderRow={this._renderRow}
renderFooter={this.props.FooterComponent && this._renderFooter}
renderSectionHeader={this.props.sections && this._renderSectionHeader}
// $FlowFixMe Invalid prop usage
renderSeparator={this.props.SeparatorComponent && this._renderSeparator}
/>
);
@@ -167,6 +173,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
} else {
invariant(!props.sections, 'Cannot have both sections and items props.');
return {
// $FlowFixMe Invalid prop usage
ds: state.ds.cloneWithRows(props.items),
sectionHeaderData,
};
@@ -284,6 +284,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
*/
recordInteraction() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
// $FlowFixMe Invalid prop usage
listRef && listRef.recordInteraction();
}
@@ -294,6 +295,7 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
*/
flashScrollIndicators() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
// $FlowFixMe Invalid prop usage
listRef && listRef.flashScrollIndicators();
}
@@ -303,20 +305,23 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
getScrollResponder(): ?ScrollView {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) {
// $FlowFixMe Invalid prop usage
return listRef.getScrollResponder();
}
}
getScrollableNode() {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) {
// $FlowFixMe Invalid prop usage
return listRef.getScrollableNode();
}
}
setNativeProps(props: Object) {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) {
// $FlowFixMe Invalid prop usage
listRef.setNativeProps(props);
}
}
@@ -924,6 +924,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
(this.props.renderScrollComponent || this._defaultRenderScrollComponent)(
scrollProps,
),
// $FlowFixMe Invalid prop usage
{
ref: this._captureScrollRef,
},
@@ -1016,6 +1017,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
'`',
);
return (
// $FlowFixMe Invalid prop usage
<ScrollView
{...props}
refreshControl={
@@ -1032,6 +1034,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
/>
);
} else {
// $FlowFixMe Invalid prop usage
return <ScrollView {...props} />;
}
};
@@ -39,6 +39,7 @@ exports.examples = [
<View>
<ScrollView
ref={scrollView => {
// $FlowFixMe Invalid prop usage
_scrollView = scrollView;
}}
automaticallyAdjustContentInsets={false}
@@ -96,18 +97,21 @@ exports.examples = [
<Button
label="Scroll to start"
onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.scrollTo({x: 0});
}}
/>
<Button
label="Scroll to end"
onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.scrollToEnd({animated: true});
}}
/>
<Button
label="Flash scroll indicators"
onPress={() => {
// $FlowFixMe Invalid prop usage
_scrollView.flashScrollIndicators();
}}
/>

0 comments on commit f19ee28

Please sign in to comment.