@@ -592,22 +592,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
592
592
this . state = initialState ;
593
593
}
594
594
595
- componentDidMount ( ) {
596
- if ( this . props . initialScrollIndex ) {
597
- this . _initialScrollIndexTimeout = setTimeout (
598
- ( ) =>
599
- /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses
600
- * an error found when Flow v0.63 was deployed. To see the error
601
- * delete this comment and run Flow. */
602
- this . scrollToIndex ( {
603
- animated : false ,
604
- index : this . props . initialScrollIndex ,
605
- } ) ,
606
- 0 ,
607
- ) ;
608
- }
609
- }
610
-
611
595
componentWillUnmount ( ) {
612
596
if ( this . _isNestedWithSameOrientation ( ) ) {
613
597
this . context . virtualizedList . unregisterAsNestedChild ( {
@@ -625,10 +609,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
625
609
tuple . viewabilityHelper . dispose ( ) ;
626
610
} ) ;
627
611
this . _fillRateHelper . deactivateAndFlush ( ) ;
628
- /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
629
- * error found when Flow v0.63 was deployed. To see the error delete this
630
- * comment and run Flow. */
631
- clearTimeout ( this . _initialScrollIndexTimeout ) ;
632
612
}
633
613
634
614
componentWillReceiveProps ( newProps : Props ) {
@@ -954,7 +934,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
954
934
_highestMeasuredFrameIndex = 0 ;
955
935
_headerLength = 0 ;
956
936
_indicesToKeys: Map < number , string > = new Map ( ) ;
957
- _initialScrollIndexTimeout = 0 ;
937
+ _hasDoneInitialScroll = false ;
958
938
_nestedChildLists: Map <
959
939
string ,
960
940
{ ref : ?VirtualizedList , state : ?ChildListState } ,
@@ -1206,6 +1186,19 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1206
1186
}
1207
1187
1208
1188
_onContentSizeChange = ( width : number , height : number ) => {
1189
+ if (
1190
+ width > 0 &&
1191
+ height > 0 &&
1192
+ this . props . initialScrollIndex != null &&
1193
+ this . props . initialScrollIndex > 0 &&
1194
+ ! this . _hasDoneInitialScroll
1195
+ ) {
1196
+ this . scrollToIndex ( {
1197
+ animated : false ,
1198
+ index : this . props . initialScrollIndex ,
1199
+ } ) ;
1200
+ this . _hasDoneInitialScroll = true ;
1201
+ }
1209
1202
if ( this . props . onContentSizeChange ) {
1210
1203
this . props . onContentSizeChange ( width , height ) ;
1211
1204
}
0 commit comments