From fb9461834ac71caf344c5ebe1b05bc9b05c494ee Mon Sep 17 00:00:00 2001 From: or-else Date: Thu, 15 Aug 2019 10:49:24 +0300 Subject: [PATCH] refactored getDerivedStateFromProps in in-place-edit --- src/widgets/in-place-edit.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/widgets/in-place-edit.jsx b/src/widgets/in-place-edit.jsx index 3d854d42..0f1229e1 100644 --- a/src/widgets/in-place-edit.jsx +++ b/src/widgets/in-place-edit.jsx @@ -21,16 +21,16 @@ export default class InPlaceEdit extends React.Component { this.handlePasswordFinished = this.handlePasswordFinished.bind(this); } - static getDerivedStateFromProps(nextProps, prevState) { + componentDidUpdate(prevProps, prevState) { // If text has changed while in read mode, update text and discard changes. // Ignore update if in edit mode. - if (prevState.initialValue != nextProps.value && !prevState.active) { - return { - initialValue: nextProps.value || '', - value: nextProps.value || '' - }; + const newValue = this.props.value || ''; + if (prevState.initialValue != newValue && !prevState.active) { + this.setState({ + initialValue: newValue, + value: newValue + }); } - return null; } handeTextChange(e) {