Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/react-native-web/src/exports/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ const Image: React.AbstractComponent<
const displayImageUri = resolveAssetUri(selectedSource);
const imageSizeStyle = resolveAssetDimensions(selectedSource);
const backgroundImage = displayImageUri ? `url("${displayImageUri}")` : null;
const backgroundSize = getBackgroundSize();
const cachedBackgroundSize = React.useRef(null);
const backgroundSize = getBackgroundSize() || cachedBackgroundSize.current;

// Accessibility image allows users to trigger the browser's image context menu
const hiddenImage = displayImageUri
Expand Down Expand Up @@ -260,7 +261,8 @@ const Image: React.AbstractComponent<
);
const x = Math.ceil(scaleFactor * naturalWidth);
const y = Math.ceil(scaleFactor * naturalHeight);
return `${x}px ${y}px`;
cachedBackgroundSize.current = `${x}px ${y}px`;
return cachedBackgroundSize.current;
}
}
}
Expand Down