@@ -402,9 +402,6 @@ export type Props = $ReadOnly<{|
402
402
* - `false`, deprecated, use 'never' instead
403
403
* - `true`, deprecated, use 'always' instead
404
404
*/
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. */
408
405
keyboardShouldPersistTaps ?: ?( 'always' | 'never' | 'handled' | false | true ) ,
409
406
/**
410
407
* Called when the momentum scroll starts (scroll which occurs as the ScrollView glides to a stop).
@@ -438,7 +435,7 @@ export type Props = $ReadOnly<{|
438
435
* It's implemented using onLayout handler attached to the content container
439
436
* which this ScrollView renders.
440
437
*/
441
- onContentSizeChange ?: ( event : ScrollEvent ) => void ,
438
+ onContentSizeChange ?: ( contentWidth : number , contentHeight : number ) => void ,
442
439
onKeyboardDidShow ?: ( event : PressEvent ) => void ,
443
440
/**
444
441
* 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> {
591
588
*/
592
589
_scrollResponder : typeof ScrollResponder . Mixin = createScrollResponder ( this ) ;
593
590
594
- constructor ( ... args ) {
595
- super ( ... args ) ;
591
+ constructor ( props : Props ) {
592
+ super ( props ) ;
596
593
597
594
/**
598
595
* Part 2: Removing ScrollResponder.Mixin
@@ -610,6 +607,7 @@ class ScrollView extends React.Component<Props, State> {
610
607
typeof ScrollResponder . Mixin [ key ] === 'function' &&
611
608
key . startsWith ( 'scrollResponder' )
612
609
) {
610
+ // $FlowFixMe - dynamically adding properties to a class
613
611
( this : any ) [ key ] = ScrollResponder . Mixin [ key ] . bind ( this ) ;
614
612
}
615
613
}
@@ -623,6 +621,7 @@ class ScrollView extends React.Component<Props, State> {
623
621
Object . keys ( ScrollResponder . Mixin )
624
622
. filter ( key => typeof ScrollResponder . Mixin [ key ] !== 'function ')
625
623
. forEach ( key => {
624
+ // $FlowFixMe - dynamically adding properties to a class
626
625
( this : any ) [ key ] = ScrollResponder . Mixin [ key ] ;
627
626
} ) ;
628
627
}
@@ -666,8 +665,7 @@ class ScrollView extends React.Component<Props, State> {
666
665
}
667
666
}
668
667
669
- // $FlowFixMe - what are the native props we can set for ScrollView?
670
- setNativeProps ( props : Object ) {
668
+ setNativeProps ( props : { [ key : string ] : mixed } ) {
671
669
this . _scrollViewRef && this . _scrollViewRef . setNativeProps ( props ) ;
672
670
}
673
671
@@ -681,6 +679,7 @@ class ScrollView extends React.Component<Props, State> {
681
679
...typeof ScrollView ,
682
680
...typeof ScrollResponder . Mixin ,
683
681
} {
682
+ // $FlowFixMe - overriding type to include ScrollResponder.Mixin
684
683
return ( ( this : any ) : {
685
684
...typeof ScrollView ,
686
685
...typeof ScrollResponder . Mixin ,
@@ -848,7 +847,7 @@ class ScrollView extends React.Component<Props, State> {
848
847
} ;
849
848
850
849
_handleLayout = ( e : LayoutEvent ) => {
851
- if ( this . props . invertStickyHeaders ) {
850
+ if ( this . props . invertStickyHeaders === true ) {
852
851
this . setState ( { layoutHeight : e . nativeEvent . layout . height } ) ;
853
852
}
854
853
if ( this . props . onLayout ) {
@@ -876,7 +875,7 @@ class ScrollView extends React.Component<Props, State> {
876
875
let ScrollViewClass ;
877
876
let ScrollContentContainerViewClass ;
878
877
if ( Platform . OS === 'android' ) {
879
- if ( this . props . horizontal ) {
878
+ if ( this . props . horizontal === true ) {
880
879
ScrollViewClass = AndroidHorizontalScrollView ;
881
880
ScrollContentContainerViewClass = AndroidHorizontalScrollContentView ;
882
881
} else {
@@ -899,10 +898,10 @@ class ScrollView extends React.Component<Props, State> {
899
898
) ;
900
899
901
900
const contentContainerStyle = [
902
- this . props . horizontal && styles . contentContainerHorizontal ,
901
+ this . props . horizontal === true && styles . contentContainerHorizontal ,
903
902
this . props . contentContainerStyle ,
904
903
] ;
905
- if ( __DEV__ && this . props . style ) {
904
+ if ( __DEV__ && this . props . style !== undefined ) {
906
905
const style = flattenStyle ( this . props . style ) ;
907
906
const childLayoutProps = [ 'alignItems' , 'justifyContent' ] . filter (
908
907
prop => style && style [ prop ] !== undefined ,
@@ -954,7 +953,7 @@ class ScrollView extends React.Component<Props, State> {
954
953
}
955
954
956
955
const hasStickyHeaders =
957
- stickyHeaderIndices && stickyHeaderIndices . length > 0 ;
956
+ Array . isArray ( stickyHeaderIndices ) && stickyHeaderIndices . length > 0 ;
958
957
959
958
const contentContainer = (
960
959
< ScrollContentContainerViewClass
@@ -987,9 +986,10 @@ class ScrollView extends React.Component<Props, State> {
987
986
const DEPRECATED_sendUpdatedChildFrames = ! ! this . props
988
987
. DEPRECATED_sendUpdatedChildFrames ;
989
988
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 ;
993
993
const props = {
994
994
...this . props ,
995
995
alwaysBounceHorizontal,
@@ -1045,12 +1045,12 @@ class ScrollView extends React.Component<Props, State> {
1045
1045
pagingEnabled : Platform . select ( {
1046
1046
// on iOS, pagingEnabled must be set to false to have snapToInterval / snapToOffsets work
1047
1047
ios :
1048
- this . props . pagingEnabled &&
1048
+ this . props . pagingEnabled === true &&
1049
1049
this . props . snapToInterval == null &&
1050
1050
this . props . snapToOffsets == null ,
1051
1051
// on Android, pagingEnabled must be set to true to have snapToInterval / snapToOffsets work
1052
1052
android :
1053
- this . props . pagingEnabled ||
1053
+ this . props . pagingEnabled === true ||
1054
1054
this . props . snapToInterval != null ||
1055
1055
this . props . snapToOffsets != null ,
1056
1056
} ) ,
0 commit comments