Rename *Component props to match SectionList

Reviewed By: yungsters

Differential Revision: D4697335

fbshipit-source-id: 742b7a1729ba7a08fe3d9707bcf6c51026779739
This commit is contained in:
Spencer Ahrens 2017-03-13 09:41:30 -07:00 committed by Facebook Github Bot
parent ac452c0a17
commit 3ce31c24da
6 changed files with 24 additions and 41 deletions

View File

@ -133,9 +133,9 @@ class FlatListExample extends React.PureComponent {
</View> </View>
<SeparatorComponent /> <SeparatorComponent />
<AnimatedFlatList <AnimatedFlatList
HeaderComponent={HeaderComponent} ItemSeparatorComponent={SeparatorComponent}
FooterComponent={FooterComponent} ListHeaderComponent={HeaderComponent}
SeparatorComponent={SeparatorComponent} ListFooterComponent={FooterComponent}
data={filteredData} data={filteredData}
debug={this.state.debug} debug={this.state.debug}
disableVirtualization={!this.state.virtualized} disableVirtualization={!this.state.virtualized}

View File

@ -97,9 +97,9 @@ class MultiColumnExample extends React.PureComponent {
</View> </View>
<SeparatorComponent /> <SeparatorComponent />
<FlatList <FlatList
FooterComponent={FooterComponent} ItemSeparatorComponent={SeparatorComponent}
HeaderComponent={HeaderComponent} ListFooterComponent={FooterComponent}
SeparatorComponent={SeparatorComponent} ListHeaderComponent={HeaderComponent}
getItemLayout={this.state.fixedHeight ? this._getItemLayout : undefined} getItemLayout={this.state.fixedHeight ? this._getItemLayout : undefined}
data={filteredData} data={filteredData}
key={this.state.numColumns + (this.state.fixedHeight ? 'f' : 'v')} key={this.state.numColumns + (this.state.fixedHeight ? 'f' : 'v')}

View File

@ -66,18 +66,18 @@ type RequiredProps<ItemT> = {
data: ?Array<ItemT>, data: ?Array<ItemT>,
}; };
type OptionalProps<ItemT> = { type OptionalProps<ItemT> = {
/**
* Rendered in between each item, but not at the top or bottom.
*/
ItemSeparatorComponent?: ?ReactClass<any>,
/** /**
* Rendered at the bottom of all the items. * Rendered at the bottom of all the items.
*/ */
FooterComponent?: ?ReactClass<any>, ListFooterComponent?: ?ReactClass<any>,
/** /**
* Rendered at the top of all the items. * Rendered at the top of all the items.
*/ */
HeaderComponent?: ?ReactClass<any>, ListHeaderComponent?: ?ReactClass<any>,
/**
* Rendered in between each item, but not at the top or bottom.
*/
SeparatorComponent?: ?ReactClass<any>,
/** /**
* `getItemLayout` is an optional optimizations that let us skip measurement of dynamic content if * `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 * you know the height of items a priori. `getItemLayout` is the most efficient, and is easy to
@ -88,7 +88,7 @@ type OptionalProps<ItemT> = {
* )} * )}
* *
* Remember to include separator length (height or width) in your offset calculation if you * Remember to include separator length (height or width) in your offset calculation if you
* specify `SeparatorComponent`. * specify `ItemSeparatorComponent`.
*/ */
getItemLayout?: (data: ?Array<ItemT>, index: number) => getItemLayout?: (data: ?Array<ItemT>, index: number) =>
{length: number, offset: number, index: number}, {length: number, offset: number, index: number},
@ -132,13 +132,6 @@ type OptionalProps<ItemT> = {
* Optional custom style for multi-item rows generated when numColumns > 1 * Optional custom style for multi-item rows generated when numColumns > 1
*/ */
columnWrapperStyle?: StyleObj, 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. * See `ViewabilityHelper` for flow type and further documentation.
*/ */

View File

@ -183,16 +183,8 @@ class SectionList<SectionT: SectionBase<any>>
static defaultProps: DefaultProps = VirtualizedSectionList.defaultProps; static defaultProps: DefaultProps = VirtualizedSectionList.defaultProps;
render() { render() {
const {ListFooterComponent, ListHeaderComponent, ItemSeparatorComponent} = this.props;
const List = this.props.legacyImplementation ? MetroListView : VirtualizedSectionList; const List = this.props.legacyImplementation ? MetroListView : VirtualizedSectionList;
return ( return <List {...this.props} />;
<List
{...this.props}
FooterComponent={ListFooterComponent}
HeaderComponent={ListHeaderComponent}
SeparatorComponent={ItemSeparatorComponent}
/>
);
} }
} }

View File

@ -59,9 +59,6 @@ type RequiredProps = {
data?: any, data?: any,
}; };
type OptionalProps = { 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 * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
* implementation, but with a significant perf hit. * implementation, but with a significant perf hit.
@ -305,6 +302,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' + 'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
'to support native onScroll events with useNativeDriver', 'to support native onScroll events with useNativeDriver',
); );
this._updateCellsToRenderBatcher = new Batchinator( this._updateCellsToRenderBatcher = new Batchinator(
this._updateCellsToRender, this._updateCellsToRender,
this.props.updateCellsBatchingPeriod, this.props.updateCellsBatchingPeriod,
@ -334,7 +332,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
} }
_pushCells(cells, first, last) { _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; const end = getItemCount(data) - 1;
last = Math.min(end, last); last = Math.min(end, last);
for (let ii = first; ii <= last; ii++) { for (let ii = first; ii <= last; ii++) {
@ -352,19 +350,19 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
parentProps={this.props} parentProps={this.props}
/> />
); );
if (SeparatorComponent && ii < end) { if (ItemSeparatorComponent && ii < end) {
cells.push(<SeparatorComponent key={'sep' + ii}/>); cells.push(<ItemSeparatorComponent key={'sep' + ii}/>);
} }
} }
} }
render() { render() {
const {FooterComponent, HeaderComponent} = this.props; const {ListFooterComponent, ListHeaderComponent} = this.props;
const {data, disableVirtualization, horizontal} = this.props; const {data, disableVirtualization, horizontal} = this.props;
const cells = []; const cells = [];
if (HeaderComponent) { if (ListHeaderComponent) {
cells.push( cells.push(
<View key="$header" onLayout={this._onLayoutHeader}> <View key="$header" onLayout={this._onLayoutHeader}>
<HeaderComponent /> <ListHeaderComponent />
</View> </View>
); );
} }
@ -404,10 +402,10 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
); );
} }
} }
if (FooterComponent) { if (ListFooterComponent) {
cells.push( cells.push(
<View key="$footer" onLayout={this._onLayoutFooter}> <View key="$footer" onLayout={this._onLayoutFooter}>
<FooterComponent /> <ListFooterComponent />
</View> </View>
); );
} }

View File

@ -84,7 +84,7 @@ type OptionalProps<SectionT: SectionBase> = {
renderSectionHeader?: ?({section: SectionT}) => ?React.Element<*>, renderSectionHeader?: ?({section: SectionT}) => ?React.Element<*>,
/** /**
* Rendered at the bottom of every Section, except the very last one, in place of the normal * Rendered at the bottom of every Section, except the very last one, in place of the normal
* SeparatorComponent. * ItemSeparatorComponent.
*/ */
SectionSeparatorComponent?: ?ReactClass<*>, SectionSeparatorComponent?: ?ReactClass<*>,
/** /**