修复一个已销毁调用 setState 的case
This commit is contained in:
parent
7fa8adec80
commit
96e42c4169
|
@ -161,6 +161,7 @@ export default class ImageControl extends React.Component<
|
|||
current: FileValue | FileX | null = null;
|
||||
resolve?: (value?: any) => void;
|
||||
emitValue: any;
|
||||
unmounted = false;
|
||||
|
||||
constructor(props: ImageProps) {
|
||||
super(props);
|
||||
|
@ -261,6 +262,10 @@ export default class ImageControl extends React.Component<
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unmounted = true;
|
||||
}
|
||||
|
||||
buildCrop(props: ImageProps) {
|
||||
let crop = props.crop;
|
||||
|
||||
|
@ -837,12 +842,13 @@ export default class ImageControl extends React.Component<
|
|||
this.current || find(files, file => file.state === 'pending')
|
||||
);
|
||||
|
||||
this.setState(
|
||||
{
|
||||
files: this.files = files
|
||||
},
|
||||
!needUploading ? this.onChange : undefined
|
||||
);
|
||||
this.unmounted ||
|
||||
this.setState(
|
||||
{
|
||||
files: this.files = files
|
||||
},
|
||||
!needUploading ? this.onChange : undefined
|
||||
);
|
||||
};
|
||||
img.src = imgDom.src;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue