Skip to content

Commit 4e6daca

Browse files
committed
[add] Image: Append source to nativeEvent
1 parent 059ab04 commit 4e6daca

File tree

1 file changed

+10
-2
lines changed
  • packages/react-native-web/src/modules/ImageLoader

1 file changed

+10
-2
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,17 @@ const ImageLoader = {
122122
id += 1;
123123
const image = new window.Image();
124124
image.onerror = onError;
125-
image.onload = (e) => {
125+
image.onload = (nativeEvent) => {
126126
// avoid blocking the main thread
127-
const onDecode = () => onLoad({ nativeEvent: e });
127+
const onDecode = () => {
128+
nativeEvent.source = {
129+
uri: image.src,
130+
width: image.naturalWidth,
131+
height: image.naturalHeight
132+
};
133+
134+
onLoad({ nativeEvent });
135+
};
128136
if (typeof image.decode === 'function') {
129137
// Safari currently throws exceptions when decoding svgs.
130138
// We want to catch that error and allow the load handler

0 commit comments

Comments
 (0)