mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
optimizing logo re-render
This commit is contained in:
parent
66813dc601
commit
3107e409b5
@ -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>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user