MM-18764 Remove deprecated lifecycles (#4981)

* create_channel: remove componentWillReceiveProps

* lint fix

* list: removed componentwillreceiveprops

* removed deprecated lifecycle methods

* removed deprecated lifecycle methods
This commit is contained in:
A C SREEDHAR REDDY 2020-12-10 21:34:32 +05:30 committed by GitHub
parent 20f210cb03
commit 6e2936e2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 28 deletions

View file

@ -80,14 +80,16 @@ class FilteredList extends Component {
return !deepEqual(this.props, nextProps, {strict: true}) || !deepEqual(this.state, nextState, {strict: true});
}
componentWillReceiveProps(nextProps) {
if (this.props.term !== nextProps.term) {
const {actions, currentTeam} = this.props;
const {term} = nextProps;
setDataSourceAndTerm(dataSource, term) {
this.setState({dataSource, term});
}
componentDidUpdate(prevProps) {
if (prevProps.term !== this.props.term) {
const {actions, currentTeam, term} = this.props;
const {searchChannels, searchProfiles} = actions;
const dataSource = this.buildData(this.props, term);
this.setState({dataSource, term});
this.setDataSourceAndTerm(dataSource, term);
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {

View file

@ -81,21 +81,23 @@ export default class List extends PureComponent {
}
}
componentWillReceiveProps(nextProps) {
setSections(sections) {
this.setState({sections});
}
componentDidUpdate(prevProps, prevState) {
const {
canCreatePrivateChannels,
orderedChannelIds,
unreadChannelIds,
} = this.props;
} = prevProps;
if (nextProps.canCreatePrivateChannels !== canCreatePrivateChannels ||
nextProps.unreadChannelIds !== unreadChannelIds ||
nextProps.orderedChannelIds !== orderedChannelIds) {
this.setState({sections: this.buildSections(nextProps)});
if (this.props.canCreatePrivateChannels !== canCreatePrivateChannels ||
this.props.unreadChannelIds !== unreadChannelIds ||
this.props.orderedChannelIds !== orderedChannelIds) {
this.setSections(this.buildSections(this.props));
}
}
componentDidUpdate(prevProps, prevState) {
if (prevState.sections !== this.state.sections && this.listRef?._wrapperListRef?.getListRef()._viewabilityHelper) { //eslint-disable-line
this.listRef.recordInteraction();
this.updateUnreadIndicators({

View file

@ -72,14 +72,20 @@ export default class CreateChannel extends PureComponent {
this.emitCanCreateChannel(false);
}
componentWillReceiveProps(nextProps) {
const {createChannelRequest} = nextProps;
onRequestStart() {
this.setState({error: null, creating: true});
}
if (this.props.createChannelRequest !== createChannelRequest) {
switch (createChannelRequest.status) {
onRequestFailure(error) {
this.setState({error, creating: false});
}
componentDidUpdate(prevProps) {
if (this.props.createChannelRequest !== prevProps.createChannelRequest) {
switch (this.props.createChannelRequest.status) {
case RequestStatus.STARTED:
this.emitCreating(true);
this.setState({error: null, creating: true});
this.onRequestStart();
break;
case RequestStatus.SUCCESS:
EventEmitter.emit(NavigationTypes.CLOSE_MAIN_SIDEBAR);
@ -91,7 +97,7 @@ export default class CreateChannel extends PureComponent {
break;
case RequestStatus.FAILURE:
this.emitCreating(false);
this.setState({error: createChannelRequest.error, creating: false});
this.onRequestFailure(this.props.createChannelRequest.error);
break;
}
}

View file

@ -102,22 +102,26 @@ export default class MoreChannels extends PureComponent {
this.mounted = false;
}
componentWillReceiveProps(nextProps) {
setChannelsOrArchivedChannels(state) {
this.setState(state);
}
componentDidUpdate(prevProps) {
const {term} = this.state;
let channels;
let archivedChannels;
if (nextProps.channels !== this.props.channels) {
channels = nextProps.channels;
if (this.props.channels !== prevProps.channels) {
channels = this.props.channels;
if (term) {
channels = this.filterChannels(nextProps.channels, term);
channels = this.filterChannels(this.props.channels, term);
}
}
if (nextProps.archivedChannels !== this.props.archivedChannels) {
archivedChannels = nextProps.archivedChannels;
if (this.props.archivedChannels !== prevProps.archivedChannels) {
archivedChannels = this.props.archivedChannels;
if (term) {
archivedChannels = this.filterChannels(nextProps.archivedChannels, term);
archivedChannels = this.filterChannels(this.props.archivedChannels, term);
}
}
@ -131,7 +135,7 @@ export default class MoreChannels extends PureComponent {
}
if (nextState.archivedChannels || nextState.channels) {
this.setState(nextState);
this.setChannelsOrArchivedChannels(nextState);
}
}