From 5d93629d54f3ad5dc4c8c430914290b35f6a7776 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Wed, 28 Feb 2024 17:15:16 +0530 Subject: [PATCH] fix: usePage hook throws an error without projectId --- web/hooks/store/use-page.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/hooks/store/use-page.ts b/web/hooks/store/use-page.ts index 8971acd2209..2d4dbd5b1b1 100644 --- a/web/hooks/store/use-page.ts +++ b/web/hooks/store/use-page.ts @@ -9,13 +9,13 @@ export const usePage = (pageId: string) => { const { projectPageMap, projectArchivedPageMap } = context.projectPages; const { projectId, workspaceSlug } = context.app.router; - if (!projectId || !workspaceSlug) throw new Error("usePage must be used within ProjectProvider"); - - if (projectPageMap[projectId] && projectPageMap[projectId][pageId]) { - return projectPageMap[projectId][pageId]; - } else if (projectArchivedPageMap[projectId] && projectArchivedPageMap[projectId][pageId]) { - return projectArchivedPageMap[projectId][pageId]; - } else { + if (!projectId || !workspaceSlug) { + console.log("usePage must be used within ProjectProvider"); return; } + + if (projectPageMap[projectId] && projectPageMap[projectId][pageId]) return projectPageMap[projectId][pageId]; + else if (projectArchivedPageMap[projectId] && projectArchivedPageMap[projectId][pageId]) + return projectArchivedPageMap[projectId][pageId]; + else return; };