Skip to content

Commit

Permalink
Add ability to pass ItemSeparatorComponent as React element
Browse files Browse the repository at this point in the history
ItemSeparatorComponent={<MySeparator/>} // new ability
ItemSeparatorComponent={MySeparator} // for old version only this variant
  • Loading branch information
retyui committed Dec 13, 2021
1 parent 20b0eba commit b2e7afb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2044,9 +2044,11 @@ class CellRenderer extends React.Component<
: this.props.onLayout;
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
// called explicitly by `ScrollViewStickyHeader`.
const itemSeparator = ItemSeparatorComponent && (
<ItemSeparatorComponent {...this.state.separatorProps} />
);
const itemSeparator = React.isValidElement(ItemSeparatorComponent)
? ItemSeparatorComponent
: ItemSeparatorComponent && (
<ItemSeparatorComponent {...this.state.separatorProps} />
);
const cellStyle = inversionStyle
? horizontal
? [styles.rowReverse, inversionStyle]
Expand Down

0 comments on commit b2e7afb

Please sign in to comment.