filtered_list : removed deprecated lifecycles and memoized dataSource (#4989)

* filtered_list: memoized dataSource instead of storing in a state

* removed deprecated lifecycles

* removed if
This commit is contained in:
A C SREEDHAR REDDY 2020-12-11 01:07:55 +05:30 committed by GitHub
parent 77bc6257ac
commit 47b62daccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ import {General} from '@mm-redux/constants';
import {sortChannelsByDisplayName} from '@mm-redux/utils/channel_utils';
import {displayUsername} from '@mm-redux/utils/user_utils';
import {t} from '@utils/i18n';
import memoize from 'memoize-one';
const VIEWABILITY_CONFIG = ListTypes.VISIBILITY_CONFIG_DEFAULTS;
@ -66,7 +67,6 @@ class FilteredList extends Component {
};
this.state = {
dataSource: this.buildData(props),
};
}
@ -331,13 +331,12 @@ class FilteredList extends Component {
return sections;
};
buildData = (props, term) => {
buildData = memoize((props) => {
if (!props.currentChannel) {
return null;
}
return this.buildSectionsForSearch(props, term);
};
return this.buildSectionsForSearch(props, props.term);
}, ([props], [prevProps]) => props.term === prevProps.term);
keyExtractor = (item) => item.id || item;
@ -378,8 +377,8 @@ class FilteredList extends Component {
};
render() {
const {testID, styles} = this.props;
const {dataSource} = this.state;
const {styles, testID} = this.props;
const dataSource = this.buildData(this.props);
return (
<View
testID={testID}