File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
src/components/scratch-image Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,13 @@ class ScratchImage extends React.PureComponent {
39
39
storage
40
40
. load ( imageSource . assetType , imageSource . assetId )
41
41
. then ( asset => {
42
- const dataURI = asset . encodeDataURI ( ) ;
43
- nextImage . setState ( {
44
- imageURI : dataURI
45
- } ) ;
42
+ if ( ! nextImage . wasUnmounted ) {
43
+ const dataURI = asset . encodeDataURI ( ) ;
44
+
45
+ nextImage . setState ( {
46
+ imageURI : dataURI
47
+ } ) ;
48
+ }
46
49
-- this . _currentJobs ;
47
50
this . loadPendingImages ( ) ;
48
51
} ) ;
@@ -58,6 +61,10 @@ class ScratchImage extends React.PureComponent {
58
61
const newState = this . _loadImageSource ( nextProps . imageSource ) ;
59
62
this . setState ( newState ) ;
60
63
}
64
+ componentWillUnmount ( ) {
65
+ this . wasUnmounted = true ;
66
+ ScratchImage . _pendingImages . delete ( this ) ;
67
+ }
61
68
/**
62
69
* Calculate the state changes necessary to load the image specified in the provided source info. If the component
63
70
* is mounted, call setState() with the return value of this function. If the component has not yet mounted, use
You can’t perform that action at this time.
0 commit comments