Skip to content

Commit

Permalink
Rename *Component props to match SectionList
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D4697335

fbshipit-source-id: 742b7a1729ba7a08fe3d9707bcf6c51026779739
  • Loading branch information
sahrens authored and facebook-github-bot committed Mar 13, 2017
1 parent ac452c0 commit 3ce31c2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Examples/UIExplorer/js/FlatListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class FlatListExample extends React.PureComponent {
</View>
<SeparatorComponent />
<AnimatedFlatList
HeaderComponent={HeaderComponent}
FooterComponent={FooterComponent}
SeparatorComponent={SeparatorComponent}
ItemSeparatorComponent={SeparatorComponent}
ListHeaderComponent={HeaderComponent}
ListFooterComponent={FooterComponent}
data={filteredData}
debug={this.state.debug}
disableVirtualization={!this.state.virtualized}
Expand Down
6 changes: 3 additions & 3 deletions Examples/UIExplorer/js/MultiColumnExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class MultiColumnExample extends React.PureComponent {
</View>
<SeparatorComponent />
<FlatList
FooterComponent={FooterComponent}
HeaderComponent={HeaderComponent}
SeparatorComponent={SeparatorComponent}
ItemSeparatorComponent={SeparatorComponent}
ListFooterComponent={FooterComponent}
ListHeaderComponent={HeaderComponent}
getItemLayout={this.state.fixedHeight ? this._getItemLayout : undefined}
data={filteredData}
key={this.state.numColumns + (this.state.fixedHeight ? 'f' : 'v')}
Expand Down
21 changes: 7 additions & 14 deletions Libraries/CustomComponents/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ type RequiredProps<ItemT> = {
};
type OptionalProps<ItemT> = {
/**
* Rendered at the bottom of all the items.
* Rendered in between each item, but not at the top or bottom.
*/
FooterComponent?: ?ReactClass<any>,
ItemSeparatorComponent?: ?ReactClass<any>,
/**
* Rendered at the top of all the items.
* Rendered at the bottom of all the items.
*/
HeaderComponent?: ?ReactClass<any>,
ListFooterComponent?: ?ReactClass<any>,
/**
* Rendered in between each item, but not at the top or bottom.
* Rendered at the top of all the items.
*/
SeparatorComponent?: ?ReactClass<any>,
ListHeaderComponent?: ?ReactClass<any>,
/**
* `getItemLayout` is an optional optimizations that let us skip measurement of dynamic content if
* you know the height of items a priori. `getItemLayout` is the most efficient, and is easy to
Expand All @@ -88,7 +88,7 @@ type OptionalProps<ItemT> = {
* )}
*
* Remember to include separator length (height or width) in your offset calculation if you
* specify `SeparatorComponent`.
* specify `ItemSeparatorComponent`.
*/
getItemLayout?: (data: ?Array<ItemT>, index: number) =>
{length: number, offset: number, index: number},
Expand Down Expand Up @@ -132,13 +132,6 @@ type OptionalProps<ItemT> = {
* Optional custom style for multi-item rows generated when numColumns > 1
*/
columnWrapperStyle?: StyleObj,
/**
* Optional optimization to minimize re-rendering items.
*/
shouldItemUpdate: (
prevInfo: {item: ItemT, index: number},
nextInfo: {item: ItemT, index: number}
) => boolean,
/**
* See `ViewabilityHelper` for flow type and further documentation.
*/
Expand Down
10 changes: 1 addition & 9 deletions Libraries/CustomComponents/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,8 @@ class SectionList<SectionT: SectionBase<any>>
static defaultProps: DefaultProps = VirtualizedSectionList.defaultProps;

render() {
const {ListFooterComponent, ListHeaderComponent, ItemSeparatorComponent} = this.props;
const List = this.props.legacyImplementation ? MetroListView : VirtualizedSectionList;
return (
<List
{...this.props}
FooterComponent={ListFooterComponent}
HeaderComponent={ListHeaderComponent}
SeparatorComponent={ItemSeparatorComponent}
/>
);
return <List {...this.props} />;
}
}

Expand Down
20 changes: 9 additions & 11 deletions Libraries/CustomComponents/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ type RequiredProps = {
data?: any,
};
type OptionalProps = {
FooterComponent?: ?ReactClass<any>,
HeaderComponent?: ?ReactClass<any>,
SeparatorComponent?: ?ReactClass<any>,
/**
* `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
* implementation, but with a significant perf hit.
Expand Down Expand Up @@ -305,6 +302,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
'to support native onScroll events with useNativeDriver',
);

this._updateCellsToRenderBatcher = new Batchinator(
this._updateCellsToRender,
this.props.updateCellsBatchingPeriod,
Expand Down Expand Up @@ -334,7 +332,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
}

_pushCells(cells, first, last) {
const {SeparatorComponent, data, getItem, getItemCount, keyExtractor} = this.props;
const {ItemSeparatorComponent, data, getItem, getItemCount, keyExtractor} = this.props;
const end = getItemCount(data) - 1;
last = Math.min(end, last);
for (let ii = first; ii <= last; ii++) {
Expand All @@ -352,19 +350,19 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
parentProps={this.props}
/>
);
if (SeparatorComponent && ii < end) {
cells.push(<SeparatorComponent key={'sep' + ii}/>);
if (ItemSeparatorComponent && ii < end) {
cells.push(<ItemSeparatorComponent key={'sep' + ii}/>);
}
}
}
render() {
const {FooterComponent, HeaderComponent} = this.props;
const {ListFooterComponent, ListHeaderComponent} = this.props;
const {data, disableVirtualization, horizontal} = this.props;
const cells = [];
if (HeaderComponent) {
if (ListHeaderComponent) {
cells.push(
<View key="$header" onLayout={this._onLayoutHeader}>
<HeaderComponent />
<ListHeaderComponent />
</View>
);
}
Expand Down Expand Up @@ -404,10 +402,10 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
);
}
}
if (FooterComponent) {
if (ListFooterComponent) {
cells.push(
<View key="$footer" onLayout={this._onLayoutFooter}>
<FooterComponent />
<ListFooterComponent />
</View>
);
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/CustomComponents/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type OptionalProps<SectionT: SectionBase> = {
renderSectionHeader?: ?({section: SectionT}) => ?React.Element<*>,
/**
* Rendered at the bottom of every Section, except the very last one, in place of the normal
* SeparatorComponent.
* ItemSeparatorComponent.
*/
SectionSeparatorComponent?: ?ReactClass<*>,
/**
Expand Down

0 comments on commit 3ce31c2

Please sign in to comment.