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);
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (prevState.dataUrl != nextProps.avatar) {
|
||||
return {
|
||||
dataUrl: nextProps.avatar
|
||||
};
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.avatar != prevProps.avatar) {
|
||||
this.setState({dataUrl: this.props.avatar})
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
handleFileUpload(e) {
|
||||
|
||||
+10
-11
@@ -6283,6 +6283,16 @@ var AvatarUpload = function (_React$Component) {
|
||||
}
|
||||
|
||||
_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",
|
||||
value: function handleFileUpload(e) {
|
||||
var _this2 = this;
|
||||
@@ -6344,17 +6354,6 @@ var AvatarUpload = function (_React$Component) {
|
||||
className: "material-icons"
|
||||
}, "file_upload")));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (prevState.dataUrl != nextProps.avatar) {
|
||||
return {
|
||||
dataUrl: nextProps.avatar
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
|
||||
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