From 3570ffe3cc9d232eee1f23a81ea9d77724d848c0 Mon Sep 17 00:00:00 2001 From: Harry Ross Date: Fri, 29 Dec 2023 16:28:33 +1100 Subject: [PATCH] Removed localstorage caching mechanism --- lib/components/MegaMenuLayout/MegaMenuLayout.tsx | 11 ++++++----- lib/hooks/useMenuItems.ts | 9 --------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/components/MegaMenuLayout/MegaMenuLayout.tsx b/lib/components/MegaMenuLayout/MegaMenuLayout.tsx index d1a9294..6c0c6b8 100644 --- a/lib/components/MegaMenuLayout/MegaMenuLayout.tsx +++ b/lib/components/MegaMenuLayout/MegaMenuLayout.tsx @@ -14,6 +14,7 @@ export interface MegaMenuWrapperProps extends React.PropsWithChildren { menuBarItems?: NavMenuGroup[]; logoOverride?: () => JSX.Element; sideActionsOverride?: () => JSX.Element; + // TODO: REmove hidePhone?: boolean; } @@ -29,7 +30,7 @@ const MegaMenuLayout: React.FC = ({ const { menuItems } = useMenuItems(menuBarItems); const Logo = logoOverride; - const SideActions = sideActionsOverride; + const RightSideActions = sideActionsOverride; return ( <> @@ -59,9 +60,9 @@ const MegaMenuLayout: React.FC = ({
{!hidePhone && } - {SideActions && ( + {RightSideActions && (
- +
)} @@ -88,9 +89,9 @@ const MegaMenuLayout: React.FC = ({ />
{!hidePhone && } - {SideActions && ( + {RightSideActions && (
- +
)} diff --git a/lib/hooks/useMenuItems.ts b/lib/hooks/useMenuItems.ts index f015d1f..9278bb2 100644 --- a/lib/hooks/useMenuItems.ts +++ b/lib/hooks/useMenuItems.ts @@ -10,10 +10,6 @@ const refreshData = async () => { const { menuGroups } = json; - if (window?.localStorage && menuGroups?.length > 0) { - window.localStorage.setItem("megamenu", JSON.stringify(menuGroups)); - } - return menuGroups; }; @@ -23,13 +19,8 @@ export const useMenuItems = ( const [menuItems, setMenuItems] = useState([]); useEffect(() => { - const cached = JSON.parse(window.localStorage.getItem("megamenu") || "[]"); - console.log("cached", cached); - if (menuBarItems) { setMenuItems(menuBarItems); - } else if (cached?.length > 0) { - setMenuItems(cached); } else { refreshData().then((data) => { setMenuItems(data);