From 91a7cfa87d487350c1dfc782d0b1fe313d35db7c Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Thu, 19 Oct 2023 16:37:40 +0200 Subject: [PATCH] Refactor logic to decide returning `` or null. Centralize all `useNotificationMessage` related logic. --- src/components/notification/NotificationComponent.tsx | 3 +-- src/core/utils/useNotificationMessage.tsx | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/notification/NotificationComponent.tsx b/src/components/notification/NotificationComponent.tsx index 31f8cdf188..0cc1303965 100644 --- a/src/components/notification/NotificationComponent.tsx +++ b/src/components/notification/NotificationComponent.tsx @@ -2,13 +2,12 @@ import React from "react"; import PromoBar from "../promo-bar/PromoBar"; interface NotificationComponentProps { - notificationMessage: string | null; + notificationMessage: string; } const NotificationComponent: React.FC = ({ notificationMessage }) => { - if (!notificationMessage) return null; return ; }; diff --git a/src/core/utils/useNotificationMessage.tsx b/src/core/utils/useNotificationMessage.tsx index 3dbc266ad6..558cc7eda2 100644 --- a/src/core/utils/useNotificationMessage.tsx +++ b/src/core/utils/useNotificationMessage.tsx @@ -28,7 +28,10 @@ export const useNotificationMessage = ({ }; return [ - () => , + () => + notificationMessage ? ( + + ) : null, handleNotificationMessage ]; };