Don't use componentWillReceiveProps

This commit is contained in:
Jenni Nurmi 2019-08-27 14:44:33 +03:00
parent 34c4903bad
commit 3720591dda
2 changed files with 6 additions and 6 deletions

View file

@ -78,14 +78,14 @@ class TokenInputFieldComponent extends Component {
this._isMounted = true;
}
componentWillReceiveProps(nextProps) {
const countryChanged = nextProps.country !== this.props.country;
const currencyChanged = nextProps.currency !== this.props.currency;
componentDidUpdate(prevProps) {
const countryChanged = this.props.country !== prevProps.country;
const currencyChanged = this.props.currency !== prevProps.currency;
if (countryChanged || currencyChanged) {
// Clear the possible input values from the state
// if the given country or currency changes.
this.setState(this.initialState);
nextProps.input.onChange('');
this.props.input.onChange('');
}
}

View file

@ -25,10 +25,10 @@ class ProfileSettingsFormComponent extends Component {
this.submittedValues = {};
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
// Upload delay is additional time window where Avatar is added to the DOM,
// but not yet visible (time to load image URL from srcset)
if (this.props.uploadInProgress && !nextProps.uploadInProgress) {
if (prevProps.uploadInProgress && !this.props.uploadInProgress) {
this.setState({ uploadDelay: true });
this.uploadDelayTimeoutId = window.setTimeout(() => {
this.setState({ uploadDelay: false });