Skip to content

Commit 42f6749

Browse files
authored
Fix ItemSeparatorComponent not updating leadingItem prop
Fix #24592
1 parent 18feded commit 42f6749

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

Libraries/Lists/VirtualizedList.js

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,26 +1667,28 @@ 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
},
1687+
prevCellKey: ?string,
1688+
}
1689+
1690+
class CellRenderer extends React.Component<
1691+
CellRendererProps,
16901692
$FlowFixMeState,
16911693
> {
16921694
state = {
@@ -1702,6 +1704,18 @@ class CellRenderer extends React.Component<
17021704
}),
17031705
};
17041706

1707+
static getDerivedStateFromProps(
1708+
props: CellRendererProps,
1709+
prevState: FlowFixMeState,
1710+
): ?FlowFixMeState {
1711+
return {
1712+
separatorProps: {
1713+
...prevState.separatorProps,
1714+
leadingItem: props.item,
1715+
},
1716+
};
1717+
};
1718+
17051719
getChildContext() {
17061720
return {
17071721
virtualizedCell: {

0 commit comments

Comments
 (0)