@@ -432,7 +432,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
432
432
} ;
433
433
434
434
static contextTypes = {
435
- virtualizedListCellRenderer : PropTypes . shape ( {
435
+ virtualizedCell : PropTypes . shape ( {
436
436
cellKey : PropTypes . string ,
437
437
} ) ,
438
438
virtualizedList : PropTypes . shape ( {
@@ -466,6 +466,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
466
466
} ;
467
467
}
468
468
469
+ _getCellKey ( ) : string {
470
+ return (
471
+ ( this . context . virtualizedCell && this . context . virtualizedCell . cellKey ) ||
472
+ 'rootList'
473
+ ) ;
474
+ }
475
+
469
476
_getScrollMetrics = ( ) => {
470
477
return this . _scrollMetrics ;
471
478
} ;
@@ -559,10 +566,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
559
566
560
567
if ( this . _isNestedWithSameOrientation ( ) ) {
561
568
const storedState = this . context . virtualizedList . registerAsNestedChild ( {
562
- cellKey : this . context . virtualizedListCellRenderer . cellKey ,
563
- key :
564
- this . props . listKey ||
565
- this . context . virtualizedListCellRenderer . cellKey ,
569
+ cellKey : this . _getCellKey ( ) ,
570
+ key : this . props . listKey || this . _getCellKey ( ) ,
566
571
ref : this ,
567
572
} ) ;
568
573
if ( storedState ) {
@@ -575,8 +580,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
575
580
this . state = initialState ;
576
581
}
577
582
578
- componentWillMount ( ) { }
579
-
580
583
componentDidMount ( ) {
581
584
if ( this . props . initialScrollIndex ) {
582
585
this . _initialScrollIndexTimeout = setTimeout (
@@ -593,9 +596,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
593
596
componentWillUnmount ( ) {
594
597
if ( this . _isNestedWithSameOrientation ( ) ) {
595
598
this . context . virtualizedList . unregisterAsNestedChild ( {
596
- key :
597
- this . props . listKey ||
598
- this . context . virtualizedListCellRenderer . cellKey ,
599
+ key : this . props . listKey || this . _getCellKey ( ) ,
599
600
state : {
600
601
first : this . state . first ,
601
602
last : this . state . last ,
@@ -743,12 +744,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
743
744
< ListHeaderComponent />
744
745
) ;
745
746
cells . push (
746
- < View
747
- key = "$header"
748
- onLayout = { this . _onLayoutHeader }
749
- style = { inversionStyle } >
750
- { element }
751
- </ View > ,
747
+ < VirtualizedCellWrapper
748
+ cellKey = { this . _getCellKey ( ) + '-header' }
749
+ key = "$header" >
750
+ < View onLayout = { this . _onLayoutHeader } style = { inversionStyle } >
751
+ { element }
752
+ </ View >
753
+ </ VirtualizedCellWrapper > ,
752
754
) ;
753
755
}
754
756
const itemCount = this . props . getItemCount ( data ) ;
@@ -867,12 +869,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
867
869
< ListFooterComponent />
868
870
) ;
869
871
cells . push (
870
- < View
871
- key = "$footer"
872
- onLayout = { this . _onLayoutFooter }
873
- style = { inversionStyle } >
874
- { element }
875
- </ View > ,
872
+ < VirtualizedCellWrapper
873
+ cellKey = { this . _getCellKey ( ) + '-footer' }
874
+ key = "$footer" >
875
+ < View onLayout = { this . _onLayoutFooter } style = { inversionStyle } >
876
+ { element }
877
+ </ View >
878
+ </ VirtualizedCellWrapper > ,
876
879
) ;
877
880
}
878
881
const scrollProps = {
@@ -1522,14 +1525,14 @@ class CellRenderer extends React.Component<
1522
1525
} ;
1523
1526
1524
1527
static childContextTypes = {
1525
- virtualizedListCellRenderer : PropTypes . shape ( {
1528
+ virtualizedCell : PropTypes . shape ( {
1526
1529
cellKey : PropTypes . string ,
1527
1530
} ) ,
1528
1531
} ;
1529
1532
1530
1533
getChildContext ( ) {
1531
1534
return {
1532
- virtualizedListCellRenderer : {
1535
+ virtualizedCell : {
1533
1536
cellKey : this . props . cellKey ,
1534
1537
} ,
1535
1538
} ;
@@ -1621,6 +1624,29 @@ class CellRenderer extends React.Component<
1621
1624
}
1622
1625
}
1623
1626
1627
+ class VirtualizedCellWrapper extends React . Component < {
1628
+ cellKey : string ,
1629
+ children : React . Node ,
1630
+ } > {
1631
+ static childContextTypes = {
1632
+ virtualizedCell : PropTypes . shape ( {
1633
+ cellKey : PropTypes . string ,
1634
+ } ) ,
1635
+ } ;
1636
+
1637
+ getChildContext ( ) {
1638
+ return {
1639
+ virtualizedCell : {
1640
+ cellKey : this . props . cellKey ,
1641
+ } ,
1642
+ } ;
1643
+ }
1644
+
1645
+ render ( ) {
1646
+ return this . props . children ;
1647
+ }
1648
+ }
1649
+
1624
1650
const styles = StyleSheet . create ( {
1625
1651
verticallyInverted : {
1626
1652
transform : [ { scaleY : - 1 } ] ,
0 commit comments