@@ -185,7 +185,7 @@ const Image: React.AbstractComponent<
185
185
) ;
186
186
}
187
187
}
188
-
188
+ const [ loadedUri , setLoadedUri ] = React . useState ( '' ) ;
189
189
const [ state , updateState ] = React . useState ( ( ) => {
190
190
const uri = resolveAssetUri ( source ) ;
191
191
if ( uri != null ) {
@@ -210,7 +210,7 @@ const Image: React.AbstractComponent<
210
210
filterRef . current
211
211
) ;
212
212
const resizeMode = props . resizeMode || _resizeMode || 'cover' ;
213
- const selectedSource = shouldDisplaySource ? source : defaultSource ;
213
+ const selectedSource = shouldDisplaySource ? loadedUri : defaultSource ;
214
214
const displayImageUri = resolveAssetUri ( selectedSource ) ;
215
215
const imageSizeStyle = resolveAssetDimensions ( selectedSource ) ;
216
216
const backgroundImage = displayImageUri ? `url("${ displayImageUri } ")` : null ;
@@ -256,22 +256,23 @@ const Image: React.AbstractComponent<
256
256
}
257
257
258
258
// Image loading
259
- const uri = resolveAssetUri ( source ) ;
260
259
React . useEffect ( ( ) => {
261
260
abortPendingRequest ( ) ;
262
261
262
+ const uri = resolveAssetUri ( source ) ;
263
263
if ( uri != null ) {
264
264
updateState ( LOADING ) ;
265
265
if ( onLoadStart ) {
266
266
onLoadStart ( ) ;
267
267
}
268
268
269
269
requestRef . current = ImageLoader . load (
270
- uri ,
271
- function load ( e ) {
270
+ { uri, headers : source ?. headers } ,
271
+ function load ( result ) {
272
272
updateState ( LOADED ) ;
273
+ setLoadedUri ( result . uri ) ;
273
274
if ( onLoad ) {
274
- onLoad ( e ) ;
275
+ onLoad ( result ) ;
275
276
}
276
277
if ( onLoadEnd ) {
277
278
onLoadEnd ( ) ;
@@ -301,7 +302,7 @@ const Image: React.AbstractComponent<
301
302
}
302
303
303
304
return abortPendingRequest ;
304
- } , [ uri , requestRef , updateState , onError , onLoad , onLoadEnd , onLoadStart ] ) ;
305
+ } , [ source , updateState , onError , onLoad , onLoadEnd , onLoadStart ] ) ;
305
306
306
307
return (
307
308
< View
0 commit comments