Don't use componentWillReceiveProps in FieldDateRangeInput

This commit is contained in:
Jenni Nurmi 2019-08-27 14:54:38 +03:00
parent 3720591dda
commit 5f7ffd737f
2 changed files with 6 additions and 6 deletions

View file

@ -138,12 +138,12 @@ class DateRangeInputComponent extends Component {
this.onFocusChange = this.onFocusChange.bind(this);
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
// Update focusedInput in case a new value for it is
// passed in the props. This may occur if the focus
// is manually set to the date picker.
if (nextProps.focusedInput && nextProps.focusedInput !== this.props.focusedInput) {
this.setState({ focusedInput: nextProps.focusedInput });
if (this.props.focusedInput && this.props.focusedInput !== prevProps.focusedInput) {
this.setState({ focusedInput: this.props.focusedInput });
}
}

View file

@ -26,12 +26,12 @@ class FieldDateRangeInputComponent extends Component {
this.handleFocus = this.handleFocus.bind(this);
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
// Update focusedInput in case a new value for it is
// passed in the props. This may occur if the focus
// is manually set to the date picker.
if (nextProps.focusedInput && nextProps.focusedInput !== this.props.focusedInput) {
this.setState({ focusedInput: nextProps.focusedInput });
if (this.props.focusedInput && this.props.focusedInput !== prevProps.focusedInput) {
this.setState({ focusedInput: this.props.focusedInput });
}
}