File tree 1 file changed +5
-2
lines changed
packages/react-native-web/src/exports/Image
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -350,7 +350,7 @@ BaseImage.displayName = 'Image';
350
350
* default source is never loaded using headers
351
351
*/
352
352
const ImageWithHeaders : ImageComponent = React . forwardRef ( ( props , ref ) => {
353
- // $FlowIgnore
353
+ // $FlowIgnore: This component would only be rendered when `source` matches `ImageSource`
354
354
const nextSource : ImageSource = props . source ;
355
355
const [ blobUri , setBlobUri ] = React . useState ( '' ) ;
356
356
const request = React . useRef < LoadRequest > ( {
@@ -373,6 +373,8 @@ const ImageWithHeaders: ImageComponent = React.forwardRef((props, ref) => {
373
373
onLoadStart ( ) ;
374
374
}
375
375
376
+ // Store a ref for the current request so when know what's the last loaded source,
377
+ // and so we can cancel it if a different source is passed through props
376
378
request . current = ImageLoader . loadWithHeaders ( nextSource ) ;
377
379
378
380
request . current . promise
@@ -388,7 +390,8 @@ const ImageWithHeaders: ImageComponent = React.forwardRef((props, ref) => {
388
390
const propsToPass = {
389
391
...props ,
390
392
391
- // Omit `onLoadStart` because we trigger it in the current scope
393
+ // `onLoadStart` is called from the current component
394
+ // We skip passing it down to prevent BaseImage raising it a 2nd time
392
395
onLoadStart : undefined ,
393
396
394
397
// Until the current component resolves the request (using headers)
You can’t perform that action at this time.
0 commit comments