remove react memo from urlImage
This commit is contained in:
parent
0c14716815
commit
251223a0c9
|
@ -52,50 +52,43 @@ const styles = StyleSheet.create({
|
||||||
imageWithoutContent: {
|
imageWithoutContent: {
|
||||||
borderRadius: 4
|
borderRadius: 4
|
||||||
},
|
},
|
||||||
activityPosition: {
|
|
||||||
zIndex: 2,
|
|
||||||
position: 'absolute'
|
|
||||||
},
|
|
||||||
loading: {
|
loading: {
|
||||||
height: 0,
|
height: 0,
|
||||||
borderWidth: 0
|
borderWidth: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const UrlImage = React.memo(
|
const UrlImage = ({
|
||||||
({
|
image,
|
||||||
image,
|
setImageLoadedState,
|
||||||
setImageLoadedState,
|
hasContent,
|
||||||
hasContent,
|
imageLoadedState
|
||||||
imageLoadedState
|
}: {
|
||||||
}: {
|
image: string;
|
||||||
image: string;
|
setImageLoadedState(value: TImageLoadedState): void;
|
||||||
setImageLoadedState(value: TImageLoadedState): void;
|
hasContent: boolean;
|
||||||
hasContent: boolean;
|
imageLoadedState: TImageLoadedState;
|
||||||
imageLoadedState: TImageLoadedState;
|
}) => {
|
||||||
}) => {
|
const { baseUrl, user } = useContext(MessageContext);
|
||||||
const { baseUrl, user } = useContext(MessageContext);
|
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
image = image.includes('http') ? image : `${baseUrl}/${image}?rc_uid=${user.id}&rc_token=${user.token}`;
|
image = image.includes('http') ? image : `${baseUrl}/${image}?rc_uid=${user.id}&rc_token=${user.token}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FastImage
|
<FastImage
|
||||||
source={{ uri: image }}
|
source={{ uri: image }}
|
||||||
style={[styles.image, !hasContent && styles.imageWithoutContent, imageLoadedState === 'loading' && styles.loading]}
|
style={[styles.image, !hasContent && styles.imageWithoutContent, imageLoadedState === 'loading' && styles.loading]}
|
||||||
resizeMode={FastImage.resizeMode.cover}
|
resizeMode={FastImage.resizeMode.cover}
|
||||||
onError={() => setImageLoadedState('error')}
|
onError={() => setImageLoadedState('error')}
|
||||||
onLoad={() => setImageLoadedState('done')}
|
onLoad={() => setImageLoadedState('done')}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
},
|
};
|
||||||
(prevProps, nextProps) => prevProps.image === nextProps.image && prevProps.imageLoadedState === nextProps.imageLoadedState
|
|
||||||
);
|
|
||||||
|
|
||||||
const UrlContent = React.memo(
|
const UrlContent = React.memo(
|
||||||
({ title, description, theme }: { title: string; description: string; theme: TSupportedThemes }) => (
|
({ title, description, theme }: { title: string; description: string; theme: TSupportedThemes }) => (
|
||||||
|
|
Loading…
Reference in New Issue