@@ -74,12 +74,13 @@ let id = 0;
7474const requests = { } ;
7575
7676const ImageLoader = {
77- abort ( requestId : number ) {
78- let image = requests [ `${ requestId } ` ] ;
77+ clear ( requestId : number ) {
78+ const image = requests [ `${ requestId } ` ] ;
7979 if ( image ) {
8080 image . onerror = null ;
8181 image . onload = null ;
82- image = null ;
82+ ImageUriCache . remove ( image . src ) ;
83+ image . src = '' ;
8384 delete requests [ `${ requestId } ` ] ;
8485 }
8586 } ,
@@ -102,7 +103,7 @@ const ImageLoader = {
102103 }
103104 }
104105 if ( complete ) {
105- ImageLoader . abort ( requestId ) ;
106+ ImageLoader . clear ( requestId ) ;
106107 clearInterval ( interval ) ;
107108 }
108109 }
@@ -111,7 +112,7 @@ const ImageLoader = {
111112 if ( typeof failure === 'function' ) {
112113 failure ( ) ;
113114 }
114- ImageLoader . abort ( requestId ) ;
115+ ImageLoader . clear ( requestId ) ;
115116 clearInterval ( interval ) ;
116117 }
117118 } ,
@@ -123,6 +124,7 @@ const ImageLoader = {
123124 const image = new window . Image ( ) ;
124125 image . onerror = onError ;
125126 image . onload = ( nativeEvent ) => {
127+ ImageUriCache . add ( uri ) ;
126128 // avoid blocking the main thread
127129 const onDecode = ( ) => {
128130 // Append `source` to match RN's ImageLoadEvent interface
@@ -185,9 +187,8 @@ const ImageLoader = {
185187 ImageLoader . load (
186188 uri ,
187189 ( ) => {
188- // Add the uri to the cache so it can be immediately displayed when used
189- // but also immediately remove it to correctly reflect that it has no active references
190- ImageUriCache . add ( uri ) ;
190+ // load() adds the uri to the cache so it can be immediately displayed when used,
191+ // but we also immediately remove it to correctly reflect that it has no active references
191192 ImageUriCache . remove ( uri ) ;
192193 resolve ( ) ;
193194 } ,
0 commit comments