@@ -190,7 +190,7 @@ const Image: React.AbstractComponent<
190
190
) ;
191
191
}
192
192
}
193
-
193
+ const [ loadedUri , setLoadedUri ] = React . useState ( '' ) ;
194
194
const [ state , updateState ] = React . useState ( ( ) => {
195
195
const uri = resolveAssetUri ( source ) ;
196
196
if ( uri != null ) {
@@ -215,7 +215,7 @@ const Image: React.AbstractComponent<
215
215
filterRef . current
216
216
) ;
217
217
const resizeMode = props . resizeMode || _resizeMode || 'cover' ;
218
- const selectedSource = shouldDisplaySource ? source : defaultSource ;
218
+ const selectedSource = shouldDisplaySource ? loadedUri : defaultSource ;
219
219
const displayImageUri = resolveAssetUri ( selectedSource ) ;
220
220
const imageSizeStyle = resolveAssetDimensions ( selectedSource ) ;
221
221
const backgroundImage = displayImageUri ? `url("${ displayImageUri } ")` : null ;
@@ -261,22 +261,23 @@ const Image: React.AbstractComponent<
261
261
}
262
262
263
263
// Image loading
264
- const uri = resolveAssetUri ( source ) ;
265
264
React . useEffect ( ( ) => {
266
265
abortPendingRequest ( ) ;
267
266
267
+ const uri = resolveAssetUri ( source ) ;
268
268
if ( uri != null ) {
269
269
updateState ( LOADING ) ;
270
270
if ( onLoadStart ) {
271
271
onLoadStart ( ) ;
272
272
}
273
273
274
274
requestRef . current = ImageLoader . load (
275
- uri ,
276
- function load ( e ) {
275
+ { uri, headers : source ?. headers } ,
276
+ function load ( result ) {
277
277
updateState ( LOADED ) ;
278
+ setLoadedUri ( result . uri ) ;
278
279
if ( onLoad ) {
279
- onLoad ( e ) ;
280
+ onLoad ( result ) ;
280
281
}
281
282
if ( onLoadEnd ) {
282
283
onLoadEnd ( ) ;
@@ -306,7 +307,7 @@ const Image: React.AbstractComponent<
306
307
}
307
308
308
309
return abortPendingRequest ;
309
- } , [ uri , requestRef , updateState , onError , onLoad , onLoadEnd , onLoadStart ] ) ;
310
+ } , [ source , updateState , onError , onLoad , onLoadEnd , onLoadStart ] ) ;
310
311
311
312
return (
312
313
< View
0 commit comments