fix avatar not being updated while edited
This commit is contained in:
@@ -17,13 +17,10 @@ export default class AvatarUpload extends React.Component {
|
|||||||
this.handleClear = this.handleClear.bind(this);
|
this.handleClear = this.handleClear.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(nextProps, prevState) {
|
componentDidUpdate(prevProps) {
|
||||||
if (prevState.dataUrl != nextProps.avatar) {
|
if (this.props.avatar != prevProps.avatar) {
|
||||||
return {
|
this.setState({dataUrl: this.props.avatar})
|
||||||
dataUrl: nextProps.avatar
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFileUpload(e) {
|
handleFileUpload(e) {
|
||||||
|
|||||||
+10
-11
@@ -6283,6 +6283,16 @@ var AvatarUpload = function (_React$Component) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_createClass(AvatarUpload, [{
|
_createClass(AvatarUpload, [{
|
||||||
|
key: "componentDidUpdate",
|
||||||
|
value: function componentDidUpdate(prevProps) {
|
||||||
|
if (this.props.avatar != prevProps.avatar) {
|
||||||
|
console.log("parent changed the avatar", prevProps.avatar, this.props.avatar);
|
||||||
|
this.setState({
|
||||||
|
dataUrl: this.props.avatar
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
key: "handleFileUpload",
|
key: "handleFileUpload",
|
||||||
value: function handleFileUpload(e) {
|
value: function handleFileUpload(e) {
|
||||||
var _this2 = this;
|
var _this2 = this;
|
||||||
@@ -6344,17 +6354,6 @@ var AvatarUpload = function (_React$Component) {
|
|||||||
className: "material-icons"
|
className: "material-icons"
|
||||||
}, "file_upload")));
|
}, "file_upload")));
|
||||||
}
|
}
|
||||||
}], [{
|
|
||||||
key: "getDerivedStateFromProps",
|
|
||||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
||||||
if (prevState.dataUrl != nextProps.avatar) {
|
|
||||||
return {
|
|
||||||
dataUrl: nextProps.avatar
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return AvatarUpload;
|
return AvatarUpload;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user