-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36275 from ikevin127/fix/34881
Android - Scan - Icons in Scan receipt context menu appear after delay
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Image} from 'expo-image'; | ||
import React, {useEffect} from 'react'; | ||
import type {ImageSourcePropType} from 'react-native'; | ||
import type ImageSVGProps from './types'; | ||
|
||
function ImageSVG({src, width = '100%', height = '100%', fill, contentFit = 'cover', style}: ImageSVGProps) { | ||
const tintColorProp = fill ? {tintColor: fill} : {}; | ||
|
||
// Clear memory cache when unmounting images to avoid memory overload | ||
useEffect(() => { | ||
const clearMemoryCache = () => Image.clearMemoryCache(); | ||
return () => { | ||
clearMemoryCache(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Image | ||
// Caching images to memory since some SVGs are being displayed with delay | ||
// See issue: https://github.com/Expensify/App/issues/34881 | ||
cachePolicy="memory" | ||
contentFit={contentFit} | ||
source={src as ImageSourcePropType} | ||
style={[{width, height}, style]} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...tintColorProp} | ||
/> | ||
); | ||
} | ||
|
||
ImageSVG.displayName = 'ImageSVG'; | ||
export default ImageSVG; |
File renamed without changes.