@@ -378,25 +378,40 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
378
378
} ;
379
379
}
380
380
381
- type ItemWithSeparatorProps = {
382
- LeadingSeparatorComponent : ?React . ComponentType < * > ,
383
- SeparatorComponent : ?React . ComponentType < * > ,
381
+ type ItemWithSeparatorCommonProps = $ReadOnly < { |
382
+ leadingItem : ?Item ,
383
+ leadingSection : ?Object ,
384
+ section : Object ,
385
+ trailingItem : ?Item ,
386
+ trailingSection : ?Object ,
387
+ | } > ;
388
+
389
+ type ItemWithSeparatorProps = $ReadOnly< { |
390
+ ...ItemWithSeparatorCommonProps ,
391
+ LeadingSeparatorComponent : ?React . ComponentType < any > ,
392
+ SeparatorComponent: ?React.ComponentType< any > ,
384
393
cellKey: string,
385
394
index: number,
386
395
item: Item,
387
396
onUpdateSeparator: (cellKey: string, newProps: Object) => void ,
388
397
prevCellKey ?: ?string ,
389
398
renderItem : Function ,
390
- section : Object ,
391
- leadingItem : ?Item ,
392
- leadingSection : ?Object ,
393
- trailingItem : ?Item ,
394
- trailingSection : ?Object ,
399
+ | } > ;
400
+
401
+ type ItemWithSeparatorState = {
402
+ separatorProps : $ReadOnly < { |
403
+ highlighted : false ,
404
+ ...ItemWithSeparatorCommonProps ,
405
+ | } > ,
406
+ leadingSeparatorProps : $ReadOnly < { |
407
+ highlighted : false ,
408
+ ...ItemWithSeparatorCommonProps ,
409
+ | } > ,
395
410
} ;
396
411
397
412
class ItemWithSeparator extends React.Component<
398
413
ItemWithSeparatorProps ,
399
- $FlowFixMeState ,
414
+ ItemWithSeparatorState ,
400
415
> {
401
416
state = {
402
417
separatorProps : {
@@ -430,7 +445,7 @@ class ItemWithSeparator extends React.Component<
430
445
} ,
431
446
updateProps: (select: 'leading' | 'trailing', newProps: Object) => {
432
447
const { LeadingSeparatorComponent, cellKey, prevCellKey} = this . props ;
433
- if ( select === 'leading' && LeadingSeparatorComponent ) {
448
+ if ( select === 'leading' && LeadingSeparatorComponent != null ) {
434
449
this. setState ( state => ( {
435
450
leadingSeparatorProps : { ...state . leadingSeparatorProps , ...newProps } ,
436
451
} ) ) ;
@@ -443,25 +458,28 @@ class ItemWithSeparator extends React.Component<
443
458
} ,
444
459
} ;
445
460
446
- UNSAFE_componentWillReceiveProps ( props : ItemWithSeparatorProps ) {
447
- this . setState ( state => ( {
461
+ static getDerivedStateFromProps (
462
+ props : ItemWithSeparatorProps ,
463
+ prevState : ItemWithSeparatorState ,
464
+ ) : ?ItemWithSeparatorState {
465
+ return {
448
466
separatorProps : {
449
- ...this . state . separatorProps ,
467
+ ...prevState . separatorProps ,
450
468
leadingItem : props . item ,
451
469
leadingSection : props . leadingSection ,
452
470
section : props . section ,
453
471
trailingItem : props . trailingItem ,
454
472
trailingSection : props . trailingSection ,
455
473
} ,
456
474
leadingSeparatorProps : {
457
- ...this . state . leadingSeparatorProps ,
475
+ ...prevState . leadingSeparatorProps ,
458
476
leadingItem : props . leadingItem ,
459
477
leadingSection : props . leadingSection ,
460
478
section : props . section ,
461
479
trailingItem : props . item ,
462
480
trailingSection : props . trailingSection ,
463
481
} ,
464
- } ) ) ;
482
+ } ;
465
483
}
466
484
467
485
updateSeparatorProps(newProps: Object) {
0 commit comments