Skip to content

Commit

Permalink
[add] Image: Append source to nativeEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
kidroca committed Feb 3, 2023
1 parent fff854c commit bedf028
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/react-native-web/src/modules/ImageLoader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,18 @@ const ImageLoader = {
id += 1;
const image = new window.Image();
image.onerror = onError;
image.onload = (e) => {
image.onload = (nativeEvent) => {
// avoid blocking the main thread
const onDecode = () => onLoad({ nativeEvent: e });
const onDecode = () => {
// Append `source` to match RN's ImageLoadEvent interface
nativeEvent.source = {
uri: image.src,
width: image.naturalWidth,
height: image.naturalHeight
};

onLoad({ nativeEvent });
};
if (typeof image.decode === 'function') {
// Safari currently throws exceptions when decoding svgs.
// We want to catch that error and allow the load handler
Expand Down

0 comments on commit bedf028

Please sign in to comment.