Skip to content

Commit f69046d

Browse files
committed
fixup moar flow issues
1 parent 1548d2d commit f69046d

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

Libraries/Components/ScrollView/ScrollView.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,6 @@ export type Props = $ReadOnly<{|
402402
* - `false`, deprecated, use 'never' instead
403403
* - `true`, deprecated, use 'always' instead
404404
*/
405-
/* $FlowFixMe(>=0.92.0 site=react_native_fb) This comment suppresses an error
406-
* found when Flow v0.92 was deployed. To see the error, delete this comment
407-
* and run Flow. */
408405
keyboardShouldPersistTaps?: ?('always' | 'never' | 'handled' | false | true),
409406
/**
410407
* Called when the momentum scroll starts (scroll which occurs as the ScrollView glides to a stop).
@@ -438,7 +435,7 @@ export type Props = $ReadOnly<{|
438435
* It's implemented using onLayout handler attached to the content container
439436
* which this ScrollView renders.
440437
*/
441-
onContentSizeChange?: (event: ScrollEvent) => void,
438+
onContentSizeChange?: (contentWidth: number, contentHeight: number) => void,
442439
onKeyboardDidShow?: (event: PressEvent) => void,
443440
/**
444441
* When true, the scroll view stops on multiples of the scroll view's size
@@ -591,8 +588,8 @@ class ScrollView extends React.Component<Props, State> {
591588
*/
592589
_scrollResponder: typeof ScrollResponder.Mixin = createScrollResponder(this);
593590

594-
constructor(...args) {
595-
super(...args);
591+
constructor(props: Props) {
592+
super(props);
596593

597594
/**
598595
* Part 2: Removing ScrollResponder.Mixin
@@ -610,6 +607,7 @@ class ScrollView extends React.Component<Props, State> {
610607
typeof ScrollResponder.Mixin[key] === 'function' &&
611608
key.startsWith('scrollResponder')
612609
) {
610+
// $FlowFixMe - dynamically adding properties to a class
613611
(this: any)[key] = ScrollResponder.Mixin[key].bind(this);
614612
}
615613
}
@@ -623,6 +621,7 @@ class ScrollView extends React.Component<Props, State> {
623621
Object.keys(ScrollResponder.Mixin)
624622
.filter(key => typeof ScrollResponder.Mixin[key] !== 'function')
625623
.forEach(key => {
624+
// $FlowFixMe - dynamically adding properties to a class
626625
(this: any)[key] = ScrollResponder.Mixin[key];
627626
});
628627
}
@@ -666,8 +665,7 @@ class ScrollView extends React.Component<Props, State> {
666665
}
667666
}
668667

669-
// $FlowFixMe - what are the native props we can set for ScrollView?
670-
setNativeProps(props: Object) {
668+
setNativeProps(props: {[key: string]: mixed}) {
671669
this._scrollViewRef && this._scrollViewRef.setNativeProps(props);
672670
}
673671

@@ -681,6 +679,7 @@ class ScrollView extends React.Component<Props, State> {
681679
...typeof ScrollView,
682680
...typeof ScrollResponder.Mixin,
683681
} {
682+
// $FlowFixMe - overriding type to include ScrollResponder.Mixin
684683
return ((this: any): {
685684
...typeof ScrollView,
686685
...typeof ScrollResponder.Mixin,
@@ -848,7 +847,7 @@ class ScrollView extends React.Component<Props, State> {
848847
};
849848

850849
_handleLayout = (e: LayoutEvent) => {
851-
if (this.props.invertStickyHeaders) {
850+
if (this.props.invertStickyHeaders === true) {
852851
this.setState({layoutHeight: e.nativeEvent.layout.height});
853852
}
854853
if (this.props.onLayout) {
@@ -876,7 +875,7 @@ class ScrollView extends React.Component<Props, State> {
876875
let ScrollViewClass;
877876
let ScrollContentContainerViewClass;
878877
if (Platform.OS === 'android') {
879-
if (this.props.horizontal) {
878+
if (this.props.horizontal === true) {
880879
ScrollViewClass = AndroidHorizontalScrollView;
881880
ScrollContentContainerViewClass = AndroidHorizontalScrollContentView;
882881
} else {
@@ -899,10 +898,10 @@ class ScrollView extends React.Component<Props, State> {
899898
);
900899

901900
const contentContainerStyle = [
902-
this.props.horizontal && styles.contentContainerHorizontal,
901+
this.props.horizontal === true && styles.contentContainerHorizontal,
903902
this.props.contentContainerStyle,
904903
];
905-
if (__DEV__ && this.props.style) {
904+
if (__DEV__ && this.props.style !== undefined) {
906905
const style = flattenStyle(this.props.style);
907906
const childLayoutProps = ['alignItems', 'justifyContent'].filter(
908907
prop => style && style[prop] !== undefined,
@@ -954,7 +953,7 @@ class ScrollView extends React.Component<Props, State> {
954953
}
955954

956955
const hasStickyHeaders =
957-
stickyHeaderIndices && stickyHeaderIndices.length > 0;
956+
Array.isArray(stickyHeaderIndices) && stickyHeaderIndices.length > 0;
958957

959958
const contentContainer = (
960959
<ScrollContentContainerViewClass
@@ -987,9 +986,10 @@ class ScrollView extends React.Component<Props, State> {
987986
const DEPRECATED_sendUpdatedChildFrames = !!this.props
988987
.DEPRECATED_sendUpdatedChildFrames;
989988

990-
const baseStyle = this.props.horizontal
991-
? styles.baseHorizontal
992-
: styles.baseVertical;
989+
const baseStyle =
990+
this.props.horizontal === true
991+
? styles.baseHorizontal
992+
: styles.baseVertical;
993993
const props = {
994994
...this.props,
995995
alwaysBounceHorizontal,
@@ -1045,12 +1045,12 @@ class ScrollView extends React.Component<Props, State> {
10451045
pagingEnabled: Platform.select({
10461046
// on iOS, pagingEnabled must be set to false to have snapToInterval / snapToOffsets work
10471047
ios:
1048-
this.props.pagingEnabled &&
1048+
this.props.pagingEnabled === true &&
10491049
this.props.snapToInterval == null &&
10501050
this.props.snapToOffsets == null,
10511051
// on Android, pagingEnabled must be set to true to have snapToInterval / snapToOffsets work
10521052
android:
1053-
this.props.pagingEnabled ||
1053+
this.props.pagingEnabled === true ||
10541054
this.props.snapToInterval != null ||
10551055
this.props.snapToOffsets != null,
10561056
}),

Libraries/Experimental/WindowedListView.js

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class WindowedListView extends React.Component<Props, State> {
208208
return (
209209
this._scrollRef &&
210210
this._scrollRef.getScrollResponder &&
211+
// $FlowFixMe - it actually returns ScrollView & ScrollResponder.Mixin
211212
this._scrollRef.getScrollResponder()
212213
);
213214
}

0 commit comments

Comments
 (0)