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.
|
// Optional props will override list-wide props just for this section.
|
||||||
renderItem?: ?(info: {item: SectionItemT, index: number}) => ?React.Element<any>,
|
renderItem?: ?(info: {item: SectionItemT, index: number}) => ?React.Element<any>,
|
||||||
SeparatorComponent?: ?ReactClass<any>,
|
ItemSeparatorComponent?: ?ReactClass<any>,
|
||||||
keyExtractor?: (item: SectionItemT) => string,
|
keyExtractor?: (item: SectionItemT) => string,
|
||||||
|
|
||||||
// TODO: support more optional/override props
|
// TODO: support more optional/override props
|
||||||
|
|
|
@ -52,7 +52,7 @@ type SectionBase = {
|
||||||
|
|
||||||
// Optional props will override list-wide props just for this section.
|
// Optional props will override list-wide props just for this section.
|
||||||
renderItem?: ?({item: SectionItem, index: number}) => ?React.Element<*>,
|
renderItem?: ?({item: SectionItem, index: number}) => ?React.Element<*>,
|
||||||
SeparatorComponent?: ?ReactClass<*>,
|
ItemSeparatorComponent?: ?ReactClass<*>,
|
||||||
keyExtractor?: (item: SectionItem) => string,
|
keyExtractor?: (item: SectionItem) => string,
|
||||||
|
|
||||||
// TODO: support more optional/override props
|
// TODO: support more optional/override props
|
||||||
|
@ -229,15 +229,15 @@ class VirtualizedSectionList<SectionT: SectionBase>
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const SeparatorComponent = info.section.SeparatorComponent || this.props.ItemSeparatorComponent;
|
const ItemSeparatorComponent = info.section.ItemSeparatorComponent || this.props.ItemSeparatorComponent;
|
||||||
const {SectionSeparatorComponent} = this.props;
|
const {SectionSeparatorComponent} = this.props;
|
||||||
const isLastItemInList = index === this.state.childProps.getItemCount() - 1;
|
const isLastItemInList = index === this.state.childProps.getItemCount() - 1;
|
||||||
const isLastItemInSection = info.index === info.section.data.length - 1;
|
const isLastItemInSection = info.index === info.section.data.length - 1;
|
||||||
if (SectionSeparatorComponent && isLastItemInSection && !isLastItemInList) {
|
if (SectionSeparatorComponent && isLastItemInSection && !isLastItemInList) {
|
||||||
return SectionSeparatorComponent;
|
return SectionSeparatorComponent;
|
||||||
}
|
}
|
||||||
if (SeparatorComponent && !isLastItemInSection && !isLastItemInList) {
|
if (ItemSeparatorComponent && !isLastItemInSection && !isLastItemInList) {
|
||||||
return SeparatorComponent;
|
return ItemSeparatorComponent;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe('SectionList', () => {
|
||||||
renderItem: ({item}) => <itemForSection1 value={item.id} />,
|
renderItem: ({item}) => <itemForSection1 value={item.id} />,
|
||||||
key: '1st Section',
|
key: '1st Section',
|
||||||
keyExtractor: (item, index) => item.id,
|
keyExtractor: (item, index) => item.id,
|
||||||
SeparatorComponent: () => <itemSeparatorForSection1 />,
|
ItemSeparatorComponent: () => <itemSeparatorForSection1 />,
|
||||||
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,7 +96,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
|
||||||
data={
|
data={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"SeparatorComponent": [Function],
|
"ItemSeparatorComponent": [Function],
|
||||||
"data": Array [
|
"data": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "i1s1",
|
"id": "i1s1",
|
||||||
|
@ -152,7 +152,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
|
||||||
sections={
|
sections={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"SeparatorComponent": [Function],
|
"ItemSeparatorComponent": [Function],
|
||||||
"data": Array [
|
"data": Array [
|
||||||
Object {
|
Object {
|
||||||
"id": "i1s1",
|
"id": "i1s1",
|
||||||
|
|
Loading…
Reference in New Issue