From cff85e37fef3e96010961ece47784dce19efb845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Wed, 7 Feb 2024 10:29:13 +0100 Subject: [PATCH] [#80] wrap with useCallback registration card texts --- .../components/organisms/DashboardCards.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/govtool/frontend/src/components/organisms/DashboardCards.tsx b/govtool/frontend/src/components/organisms/DashboardCards.tsx index 8eb669fd5..d8ec4bccb 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards.tsx @@ -213,7 +213,7 @@ export const DashboardCards = () => { formHexToBech32, ]); - const getRegistrationCardDescription = () => { + const getRegistrationCardDescription = useCallback(() => { if (registerTransaction.transactionHash) { switch (registerTransaction.type) { case "retirement": @@ -228,9 +228,14 @@ export const DashboardCards = () => { } else { return t("dashboard.registration.ifYouWant"); } - }; + }, [ + registerTransaction.transactionHash, + registerTransaction.type, + dRep?.isRegistered, + dRep?.wasRegistered, + ]); - const getRegistrationCardTitle = () => { + const getRegistrationCardTitle = useCallback(() => { if (registerTransaction?.transactionHash) { switch (registerTransaction.type) { case "retirement": @@ -247,7 +252,12 @@ export const DashboardCards = () => { } else { return t("dashboard.registration.registerAsDRep"); } - }; + }, [ + registerTransaction?.transactionHash, + registerTransaction.type, + dRep?.isRegistered, + dRep?.wasRegistered, + ]); const renderGovActionSection = useCallback(() => { return (