replace getDerivedStateFromProps with componentDidUpdate

This commit is contained in:
or-else
2019-08-12 11:51:44 +03:00
parent d2975f0c20
commit a79373c8cd
5 changed files with 18 additions and 15 deletions
+6 -4
View File
@@ -13,10 +13,12 @@ export default class ErrorPanel extends React.PureComponent {
this.hide = this.hide.bind(this); this.hide = this.hide.bind(this);
} }
static getDerivedStateFromProps(nextProps, prevState) { componentDidUpdate(prevProps) {
return { if (prevProps.level !== this.props.level) {
show: !(!nextProps.level) this.setState({
}; show: !(!this.props.level)
});
}
} }
hide() { hide() {
+9 -8
View File
@@ -6286,7 +6286,6 @@ var AvatarUpload = function (_React$Component) {
key: "componentDidUpdate", key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) { value: function componentDidUpdate(prevProps) {
if (this.props.avatar != prevProps.avatar) { if (this.props.avatar != prevProps.avatar) {
console.log("parent changed the avatar", prevProps.avatar, this.props.avatar);
this.setState({ this.setState({
dataUrl: this.props.avatar dataUrl: this.props.avatar
}); });
@@ -7927,6 +7926,15 @@ var ErrorPanel = function (_React$PureComponent) {
} }
_createClass(ErrorPanel, [{ _createClass(ErrorPanel, [{
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.level !== this.props.level) {
this.setState({
show: !!this.props.level
});
}
}
}, {
key: "hide", key: "hide",
value: function hide() { value: function hide() {
this.setState({ this.setState({
@@ -7966,13 +7974,6 @@ var ErrorPanel = function (_React$PureComponent) {
onCancel: this.hide onCancel: this.hide
}))); })));
} }
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(nextProps, prevState) {
return {
show: !!nextProps.level
};
}
}]); }]);
return ErrorPanel; return ErrorPanel;
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long