optimizing logo re-render

This commit is contained in:
balzack 2022-10-15 10:02:43 -07:00
parent 66813dc601
commit 3107e409b5

View File

@ -1,3 +1,4 @@
import { useState } from 'react';
import { Image, View } from 'react-native';
import avatar from 'images/avatar.png';
import appstore from 'images/appstore.png';
@ -5,25 +6,32 @@ import solution from 'images/solution.png';
import team from 'images/team.png';
export function Logo({ src, width, height, radius }) {
const [source, setSource] = useState(null);
if (src != source) {
setSource(src);
}
return (
<View style={{ borderRadius: radius, overflow: 'hidden', width, height }}>
{ src === 'team' && (
{ source === 'team' && (
<Image source={team} style={{ width, height }} />
)}
{ src === 'avatar' && (
{ source === 'avatar' && (
<Image source={avatar} style={{ width, height }} />
)}
{ src === 'appstore' && (
{ source === 'appstore' && (
<Image source={appstore} style={{ width, height }} />
)}
{ src === 'solution' && (
{ source === 'solution' && (
<Image source={solution} style={{ width, height }} />
)}
{ !src && (
{ !source && (
<Image source={avatar} style={{ width, height }} />
)}
{ src && src.startsWith('http') && (
<Image source={{ uri:src }} resizeMode={'contain'} style={{ width, height }} />
{ source && source.startsWith('http') && (
<Image source={{ uri:source }} resizeMode={'contain'} style={{ width, height }} />
)}
</View>
);