Skip to content

Commit 7e2d106

Browse files
kidrocamarcaaron
andauthored
Apply suggestions from code review
Co-authored-by: Marc Glasser <[email protected]>
1 parent 93df02a commit 7e2d106

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,16 @@ const ImageWithHeaders: ImageComponent = React.forwardRef((props, ref) => {
362362
const { onError, onLoadStart, onLoadEnd } = props;
363363

364364
React.useEffect(() => {
365-
if (!hasSourceDiff(nextSource, request.current.source)) return;
365+
if (!hasSourceDiff(nextSource, request.current.source)) {
366+
return;
367+
}
366368

367369
// When source changes we want to clean up any old/running requests
368370
request.current.cancel();
369371

370-
if (onLoadStart) onLoadStart();
372+
if (onLoadStart) {
373+
onLoadStart();
374+
}
371375

372376
request.current = ImageLoader.loadWithHeaders(nextSource);
373377

@@ -383,8 +387,10 @@ const ImageWithHeaders: ImageComponent = React.forwardRef((props, ref) => {
383387

384388
const propsToPass = {
385389
...props,
390+
386391
// Omit `onLoadStart` because we trigger it in the current scope
387392
onLoadStart: undefined,
393+
388394
// Until the current component resolves the request (using headers)
389395
// we skip forwarding the source so the base component doesn't attempt
390396
// to load the original source

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ const ImageLoader = {
150150
},
151151
loadWithHeaders(source: ImageSource): LoadRequest {
152152
let uri: string;
153-
const abortCtrl = new AbortController();
153+
const abortController = new AbortController();
154154
const request = new Request(source.uri, {
155155
headers: source.headers,
156-
signal: abortCtrl.signal
156+
signal: abortController.signal
157157
});
158158
request.headers.append('accept', 'image/*');
159159

@@ -175,7 +175,7 @@ const ImageLoader = {
175175
promise,
176176
source,
177177
cancel: () => {
178-
abortCtrl.abort();
178+
abortController.abort();
179179
URL.revokeObjectURL(uri);
180180
}
181181
};

0 commit comments

Comments
 (0)