From 358b2ed993946d65799004641cb116eb93d5a9a8 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Thu, 12 Nov 2020 14:56:45 +0100 Subject: [PATCH] only instantiate confirmAlert if needed --- .../branches/containers/DeleteBranch.tsx | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/scm-ui/ui-webapp/src/repos/branches/containers/DeleteBranch.tsx b/scm-ui/ui-webapp/src/repos/branches/containers/DeleteBranch.tsx index 2319b8cc54..820c09740b 100644 --- a/scm-ui/ui-webapp/src/repos/branches/containers/DeleteBranch.tsx +++ b/scm-ui/ui-webapp/src/repos/branches/containers/DeleteBranch.tsx @@ -49,24 +49,27 @@ const DeleteBranch: FC = ({ repository, branch }: Props) => { return null; } - const confirmAlert = ( - deleteBranch() - }, - { - label: t("branch.delete.confirmAlert.cancel"), - onClick: () => null - } - ]} - close={() => setShowConfirmAlert(false)} - /> - ); + let confirmAlert = null; + if (showConfirmAlert) { + confirmAlert = ( + deleteBranch() + }, + { + label: t("branch.delete.confirmAlert.cancel"), + onClick: () => null + } + ]} + close={() => setShowConfirmAlert(false)} + /> + ); + } return ( <>