change section-specific SeparatorComponent -> ItemSeparatorComponent for consistency
Summary: Not sure how I missed this in 3ce31c24da
Reviewed By: yungsters
Differential Revision: D4731083
fbshipit-source-id: 860ed9d2f99312cd02b84ba467ba66afc5cdd5c5
This commit is contained in:
parent
5c856150ff
commit
1531f5f284
|
@ -49,7 +49,7 @@ type SectionBase<SectionItemT> = {
|
|||
|
||||
// Optional props will override list-wide props just for this section.
|
||||
renderItem?: ?(info: {item: SectionItemT, index: number}) => ?React.Element<any>,
|
||||
SeparatorComponent?: ?ReactClass<any>,
|
||||
ItemSeparatorComponent?: ?ReactClass<any>,
|
||||
keyExtractor?: (item: SectionItemT) => string,
|
||||
|
||||
// TODO: support more optional/override props
|
||||
|
|
|
@ -52,7 +52,7 @@ type SectionBase = {
|
|||
|
||||
// Optional props will override list-wide props just for this section.
|
||||
renderItem?: ?({item: SectionItem, index: number}) => ?React.Element<*>,
|
||||
SeparatorComponent?: ?ReactClass<*>,
|
||||
ItemSeparatorComponent?: ?ReactClass<*>,
|
||||
keyExtractor?: (item: SectionItem) => string,
|
||||
|
||||
// TODO: support more optional/override props
|
||||
|
@ -229,15 +229,15 @@ class VirtualizedSectionList<SectionT: SectionBase>
|
|||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
const SeparatorComponent = info.section.SeparatorComponent || this.props.ItemSeparatorComponent;
|
||||
const ItemSeparatorComponent = info.section.ItemSeparatorComponent || this.props.ItemSeparatorComponent;
|
||||
const {SectionSeparatorComponent} = this.props;
|
||||
const isLastItemInList = index === this.state.childProps.getItemCount() - 1;
|
||||
const isLastItemInSection = info.index === info.section.data.length - 1;
|
||||
if (SectionSeparatorComponent && isLastItemInSection && !isLastItemInList) {
|
||||
return SectionSeparatorComponent;
|
||||
}
|
||||
if (SeparatorComponent && !isLastItemInSection && !isLastItemInList) {
|
||||
return SeparatorComponent;
|
||||
if (ItemSeparatorComponent && !isLastItemInSection && !isLastItemInList) {
|
||||
return ItemSeparatorComponent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ describe('SectionList', () => {
|
|||
renderItem: ({item}) => <itemForSection1 value={item.id} />,
|
||||
key: '1st Section',
|
||||
keyExtractor: (item, index) => item.id,
|
||||
SeparatorComponent: () => <itemSeparatorForSection1 />,
|
||||
ItemSeparatorComponent: () => <itemSeparatorForSection1 />,
|
||||
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -96,7 +96,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
|
|||
data={
|
||||
Array [
|
||||
Object {
|
||||
"SeparatorComponent": [Function],
|
||||
"ItemSeparatorComponent": [Function],
|
||||
"data": Array [
|
||||
Object {
|
||||
"id": "i1s1",
|
||||
|
@ -152,7 +152,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
|
|||
sections={
|
||||
Array [
|
||||
Object {
|
||||
"SeparatorComponent": [Function],
|
||||
"ItemSeparatorComponent": [Function],
|
||||
"data": Array [
|
||||
Object {
|
||||
"id": "i1s1",
|
||||
|
|
Loading…
Reference in New Issue