import React from 'react'; import { Image, ImageProps, StyleSheet } from 'react-native'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { getUrlWithoutParams, isLocalUrl, makeImageCompatibleUrl } from '../../utils/utils'; export type GalleryImageWithContextProps = GalleryImageProps & { ImageComponent?: React.ComponentType; }; export const GalleryImageWithContext = (props: GalleryImageWithContextProps) => { const { ImageComponent = Image, uri, style, ...rest } = props; // Caching image components such as FastImage will not work with local images. // This for the case of local uris, we use the default Image component. if (!isLocalUrl(uri)) { return ( ); } return ( ); }; export const MemoizedGalleryImage = React.memo( GalleryImageWithContext, (prevProps, nextProps) => getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri), ); export type GalleryImageProps = Omit & { uri: string; }; export const GalleryImage = (props: GalleryImageProps) => { const { ImageComponent } = useComponentsContext(); return ; }; const styles = StyleSheet.create({ image: { flex: 1, }, });