Skip to content

Commit

Permalink
fix: usePage hook throws an error without projectId (#3827)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 authored Feb 28, 2024
1 parent 0215b69 commit c4028ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions web/hooks/store/use-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit c4028ef

Please sign in to comment.