Skip to content

Commit 51f7e9a

Browse files
committed
Cleanup
1 parent 1e54c64 commit 51f7e9a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

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

+14-11
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function raiseOnErrorEvent(uri, { onError, onLoadEnd }) {
157157
}
158158
if (onLoadEnd) onLoadEnd();
159159
}
160+
160161
function hasSourceDiff(a: ImageSource, b: ImageSource) {
161162
return (
162163
a.uri !== b.uri || JSON.stringify(a.headers) !== JSON.stringify(b.headers)
@@ -391,25 +392,27 @@ const ImageWithHeaders: ImageComponent = React.forwardRef((props, ref) => {
391392
});
392393

393394
// $FlowIgnore: This is the correct type, but casting makes it unhappy since the variables aren't defined yet
394-
const Image: ImageComponent & ImageStatics = React.forwardRef((props, ref) => {
395-
if (props.source && props.source.headers) {
396-
return <ImageWithHeaders ref={ref} {...props} />;
397-
}
395+
const ImageWithStatics: ImageComponent & ImageStatics = React.forwardRef(
396+
(props, ref) => {
397+
if (props.source && props.source.headers) {
398+
return <ImageWithHeaders ref={ref} {...props} />;
399+
}
398400

399-
return <BaseImage ref={ref} {...props} />;
400-
});
401+
return <BaseImage ref={ref} {...props} />;
402+
}
403+
);
401404

402-
Image.displayName = 'Image';
405+
ImageWithStatics.displayName = 'Image';
403406

404-
Image.getSize = function (uri, success, failure) {
407+
ImageWithStatics.getSize = function (uri, success, failure) {
405408
ImageLoader.getSize(uri, success, failure);
406409
};
407410

408-
Image.prefetch = function (uri) {
411+
ImageWithStatics.prefetch = function (uri) {
409412
return ImageLoader.prefetch(uri);
410413
};
411414

412-
Image.queryCache = function (uris) {
415+
ImageWithStatics.queryCache = function (uris) {
413416
return ImageLoader.queryCache(uris);
414417
};
415418

@@ -465,4 +468,4 @@ const resizeModeStyles = StyleSheet.create({
465468
}
466469
});
467470

468-
export default Image;
471+
export default ImageWithStatics;

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

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const ImageLoader = {
125125
image.onload = (nativeEvent) => {
126126
// avoid blocking the main thread
127127
const onDecode = () => {
128+
// Append `source` to match RN's ImageLoadEvent interface
128129
nativeEvent.source = {
129130
uri: image.src,
130131
width: image.naturalWidth,

0 commit comments

Comments
 (0)