Skip to content

Commit

Permalink
Cleanup legacyImplementation code from FlatList
Browse files Browse the repository at this point in the history
Summary:
This functionality was removed here: 636d01b

This is just a step of cleanup

Reviewed By: yungsters

Differential Revision: D10515512

fbshipit-source-id: 6d24cc9c53c71924a82c67a4058585ee978de2d9
  • Loading branch information
elicwhite authored and facebook-github-bot committed Oct 24, 2018
1 parent dc74975 commit af4903e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 251 deletions.
61 changes: 12 additions & 49 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
'use strict';

const deepDiffer = require('deepDiffer');
const MetroListView = require('MetroListView'); // Used as a fallback legacy option
const React = require('React');
const View = require('View');
const VirtualizedList = require('VirtualizedList');
const ListView = require('ListView');
const StyleSheet = require('StyleSheet');

const invariant = require('fbjs/lib/invariant');
Expand Down Expand Up @@ -359,7 +357,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
viewPosition?: number,
}) {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
this._listRef.scrollToIndex(params);
}
}
Expand All @@ -376,7 +373,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
viewPosition?: number,
}) {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
this._listRef.scrollToItem(params);
}
}
Expand All @@ -388,7 +384,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
*/
scrollToOffset(params: {animated?: ?boolean, offset: number}) {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
this._listRef.scrollToOffset(params);
}
}
Expand All @@ -400,7 +395,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
*/
recordInteraction() {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
this._listRef.recordInteraction();
}
}
Expand All @@ -412,7 +406,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
*/
flashScrollIndicators() {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
this._listRef.flashScrollIndicators();
}
}
Expand All @@ -422,14 +415,12 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
*/
getScrollResponder() {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
return this._listRef.getScrollResponder();
}
}

getScrollableNode() {
if (this._listRef) {
// $FlowFixMe Found when typing ListView
return this._listRef.getScrollableNode();
}
}
Expand Down Expand Up @@ -488,8 +479,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
this._checkProps(this.props);
}

_hasWarnedLegacy = false;
_listRef: null | VirtualizedList | ListView | MetroListView;
_listRef: ?React.ElementRef<typeof VirtualizedList>;
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];

_captureRef = ref => {
Expand All @@ -501,7 +491,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
getItem,
getItemCount,
horizontal,
legacyImplementation,
numColumns,
columnWrapperStyle,
onViewableItemsChanged,
Expand All @@ -519,22 +508,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
'columnWrapperStyle not supported for single column lists',
);
}
if (legacyImplementation) {
invariant(
numColumns === 1,
'Legacy list does not support multiple columns.',
);
// Warning: may not have full feature parity and is meant more for debugging and performance
// comparison.
if (!this._hasWarnedLegacy) {
console.warn(
'FlatList: legacyImplementation is deprecated and will be removed in a ' +
'future release - some features not supported and performance may suffer. ' +
'Please migrate to the default implementation.',
);
this._hasWarnedLegacy = true;
}
}
invariant(
!(onViewableItemsChanged && viewabilityConfigCallbackPairs),
'FlatList does not support setting both onViewableItemsChanged and ' +
Expand Down Expand Up @@ -648,27 +621,17 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
};

render() {
if (this.props.legacyImplementation) {
return (
<MetroListView
{...this.props}
items={this.props.data}
ref={this._captureRef}
/>
);
} else {
return (
<VirtualizedList
{...this.props}
renderItem={this._renderItem}
getItem={this._getItem}
getItemCount={this._getItemCount}
keyExtractor={this._keyExtractor}
ref={this._captureRef}
viewabilityConfigCallbackPairs={this._virtualizedListPairs}
/>
);
}
return (
<VirtualizedList
{...this.props}
renderItem={this._renderItem}
getItem={this._getItem}
getItemCount={this._getItemCount}
keyExtractor={this._keyExtractor}
ref={this._captureRef}
viewabilityConfigCallbackPairs={this._virtualizedListPairs}
/>
);
}
}

Expand Down
202 changes: 0 additions & 202 deletions Libraries/Lists/MetroListView.js

This file was deleted.

0 comments on commit af4903e

Please sign in to comment.