[MM-18765] remove lifecycle methods from settings (#4596)

This commit is contained in:
Rahim Rahman 2020-08-12 09:10:48 -06:00 committed by GitHub
parent 27849beed4
commit 18d1dcbc09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 48 deletions

View file

@ -17,41 +17,11 @@ export default class RadioButtonGroup extends PureComponent {
options: [],
};
constructor(props) {
super(props);
this.state = {
selected: this.getSelectedValue(props.options),
};
}
componentWillReceiveProps(nextProps) {
if (this.props.options !== nextProps.options) {
this.setState({selected: this.getSelectedValue(nextProps.options)});
}
}
getSelectedValue = (options = []) => {
let selected;
for (const option in options) {
if (option.checked) {
selected = option.value;
break;
}
}
return selected;
}
onChange = (value) => {
const {onSelect} = this.props;
this.setState({
selected: value,
}, () => {
if (onSelect) {
onSelect(value);
}
});
if (onSelect) {
onSelect(value);
}
};
render = () => {

View file

@ -40,10 +40,10 @@ export default class NotificationSettings extends PureComponent {
intl: intlShape.isRequired,
};
componentWillReceiveProps(nextProps) {
const {updateMeRequest} = nextProps;
componentDidUpdate(prevProps) {
const {updateMeRequest} = this.props;
const {intl} = this.context;
if (this.props.updateMeRequest !== updateMeRequest && updateMeRequest.status === RequestStatus.FAILURE) {
if (prevProps.updateMeRequest.status !== updateMeRequest.status && updateMeRequest.status === RequestStatus.FAILURE) {
Alert.alert(
intl.formatMessage({
id: 'mobile.notification_settings.save_failed_title',

View file

@ -44,19 +44,29 @@ export default class NotificationSettingsEmailBase extends PureComponent {
this.navigationEventListener = Navigation.events().bindComponent(this);
}
componentWillReceiveProps(nextProps) {
componentDidDisappear() {
if (this.getPlatformOS() === 'ios') {
this.saveEmailNotifyProps();
}
}
componentDidUpdate(prevProps) {
this.setEmailIntervalIfNeeded(prevProps);
}
setEmailIntervalIfNeeded = (prevProps) => {
const {
notifyProps,
sendEmailNotifications,
enableEmailBatching,
emailInterval,
} = nextProps;
} = this.props;
if (
this.props.sendEmailNotifications !== sendEmailNotifications ||
this.props.enableEmailBatching !== enableEmailBatching ||
this.props.emailInterval !== emailInterval ||
this.props.notifyProps?.email !== notifyProps?.email
sendEmailNotifications !== prevProps.sendEmailNotifications ||
enableEmailBatching !== prevProps.enableEmailBatching ||
emailInterval !== prevProps.emailInterval ||
notifyProps?.email !== prevProps.notifyProps?.email
) {
this.setState({
emailInterval,
@ -65,12 +75,6 @@ export default class NotificationSettingsEmailBase extends PureComponent {
}
}
componentDidDisappear() {
if (this.getPlatformOS() === 'ios') {
this.saveEmailNotifyProps();
}
}
getPlatformOS = () => {
return Platform.OS;
}