@@ -1667,27 +1667,36 @@ class VirtualizedList extends React.PureComponent<Props, State> {
16671667 }
16681668}
16691669
1670- class CellRenderer extends React . Component <
1671- {
1672- CellRendererComponent ?: ?React . ComponentType < any > ,
1673- ItemSeparatorComponent : ?React . ComponentType < * > ,
1674- cellKey : string ,
1675- fillRateHelper : FillRateHelper ,
1676- horizontal : ?boolean ,
1677- index : number ,
1678- inversionStyle : ViewStyleProp ,
1679- item : Item ,
1680- onLayout : ( event : Object ) => void , // This is extracted by ScrollViewStickyHeader
1681- onUnmount : ( cellKey : string ) => void ,
1682- onUpdateSeparators : ( cellKeys : Array < ?string > , props : Object ) => void ,
1683- parentProps : {
1684- getItemLayout ?: ?Function ,
1685- renderItem ?: ?RenderItemType < Item > ,
1686- ListItemComponent ?: ?( React . ComponentType < any > | React . Element < any > ) ,
1687- } ,
1688- prevCellKey : ?string ,
1670+ type CellRendererProps = {
1671+ CellRendererComponent ?: ?React . ComponentType < any > ,
1672+ ItemSeparatorComponent : ?React . ComponentType < * > ,
1673+ cellKey : string ,
1674+ fillRateHelper : FillRateHelper ,
1675+ horizontal : ?boolean ,
1676+ index : number ,
1677+ inversionStyle : ViewStyleProp ,
1678+ item : Item ,
1679+ onLayout : ( event : Object ) = > void , // This is extracted by ScrollViewStickyHeader
1680+ onUnmount : ( cellKey : string ) = > void ,
1681+ onUpdateSeparators : ( cellKeys : Array < ?string > , props : Object ) = > void ,
1682+ parentProps : {
1683+ getItemLayout ?: ?Function ,
1684+ renderItem ?: ?RenderItemType < Item > ,
1685+ ListItemComponent ?: ?( React . ComponentType < any > | React . Element < any > ) ,
16891686 } ,
1690- $FlowFixMeState ,
1687+ prevCellKey : ?string ,
1688+ } ;
1689+
1690+ type CellRendererState = {
1691+ separatorProps : $ReadOnly < { |
1692+ highlighted : boolean ,
1693+ leadingItem : ?Item ,
1694+ | } > ,
1695+ } ;
1696+
1697+ class CellRenderer extends React . Component <
1698+ CellRendererProps ,
1699+ CellRendererState ,
16911700> {
16921701 state = {
16931702 separatorProps : {
@@ -1702,6 +1711,18 @@ class CellRenderer extends React.Component<
17021711 } ) ,
17031712 } ;
17041713
1714+ static getDerivedStateFromProps (
1715+ props : CellRendererProps ,
1716+ prevState : CellRendererState ,
1717+ ) : ?CellRendererState {
1718+ return {
1719+ separatorProps : {
1720+ ...prevState . separatorProps ,
1721+ leadingItem : props . item ,
1722+ } ,
1723+ } ;
1724+ }
1725+
17051726 getChildContext ( ) {
17061727 return {
17071728 virtualizedCell : {
0 commit comments