From cc251e4378c792729bb64e1e13fb6b01d1ef106f Mon Sep 17 00:00:00 2001 From: Benjamin Cabanes <3447705+bcabanes@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:42:27 -0500 Subject: [PATCH] docs(nx-dev): use localstorage for livestream banner (#28880) --- nx-dev/ui-common/src/lib/live-stream-notifier.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nx-dev/ui-common/src/lib/live-stream-notifier.tsx b/nx-dev/ui-common/src/lib/live-stream-notifier.tsx index 872d0d5ac4c91..89bc8848a473b 100644 --- a/nx-dev/ui-common/src/lib/live-stream-notifier.tsx +++ b/nx-dev/ui-common/src/lib/live-stream-notifier.tsx @@ -11,12 +11,12 @@ import { } from '@heroicons/react/24/outline'; export function LiveStreamNotifier(): ReactElement | null { + const [isMounted, setIsMounted] = useState(false); const [isVisible, setIsVisible] = useState(true); useEffect(() => { - const isClosedSession = sessionStorage.getItem( - 'live-stream-notifier-closed' - ); + setIsMounted(true); + const isClosedSession = localStorage.getItem('live-stream-notifier-closed'); if (isClosedSession === 'true') { setIsVisible(false); } @@ -25,10 +25,10 @@ export function LiveStreamNotifier(): ReactElement | null { const closeNotifier = (e: React.MouseEvent) => { e.stopPropagation(); setIsVisible(false); - sessionStorage.setItem('live-stream-notifier-closed', 'true'); + localStorage.setItem('live-stream-notifier-closed', 'true'); }; - if (!isVisible) return null; + if (!isMounted || !isVisible) return null; return (