Skip to content

Commit d90e85c

Browse files
committed
Image code comments
1 parent 7b9f633 commit d90e85c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/react-native-web/src/exports/Image/__tests__/index-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ describe('components/Image', () => {
386386
);
387387

388388
// Both defaultSource and source are loaded at the same time
389-
// But we assume defaultSource is loaded quicker
389+
// Since `defaultSource` is meant to be displayed until `source` loads
390+
// we resolve it first (otherwise it won't be displayed at all)
390391
act(() => {
391392
const call = calls.find(({ source }) => source.uri === defaultUri);
392393
call.onLoad({ source: call.source });

packages/react-native-web/src/modules/ImageLoader/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const ImageLoader = {
8686

8787
image.onerror = null;
8888
image.onload = null;
89+
// Setting image.src to empty string aborts any ongoing image loading
8990
image.src = '';
9091
ImageUriCache.remove(source.uri);
9192
delete requests[requestId];
@@ -157,7 +158,7 @@ const ImageLoader = {
157158
image.onload = handleLoad;
158159
requests[id] = { image, source };
159160

160-
// When headers are supplied we can't load the image through `image.src`, but we `fetch` it as an AJAX request
161+
// It's not possible to use headers with `image.src`, that's why we use a different strategy for sources with headers
161162
if (source.headers) {
162163
const abortCtrl = new AbortController();
163164
const request = new Request(source.uri, {

0 commit comments

Comments
 (0)