From 3107e409b5fe9c6c8be81dd123d1c05a4fb53a8a Mon Sep 17 00:00:00 2001 From: balzack Date: Sat, 15 Oct 2022 10:02:43 -0700 Subject: [PATCH] optimizing logo re-render --- app/mobile/src/utitls/Logo.jsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/mobile/src/utitls/Logo.jsx b/app/mobile/src/utitls/Logo.jsx index 6c94c38e..86de9b3a 100644 --- a/app/mobile/src/utitls/Logo.jsx +++ b/app/mobile/src/utitls/Logo.jsx @@ -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 ( - { src === 'team' && ( + { source === 'team' && ( )} - { src === 'avatar' && ( + { source === 'avatar' && ( )} - { src === 'appstore' && ( + { source === 'appstore' && ( )} - { src === 'solution' && ( + { source === 'solution' && ( )} - { !src && ( + { !source && ( )} - { src && src.startsWith('http') && ( - + { source && source.startsWith('http') && ( + )} );