diff --git a/src/renderers/Form/Image.tsx b/src/renderers/Form/Image.tsx index ab25a454..cef2f080 100644 --- a/src/renderers/Form/Image.tsx +++ b/src/renderers/Form/Image.tsx @@ -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; }