forked from github/plane
fix: usePage hook throws an error without projectId (#3827)
This commit is contained in:
parent
0215b697a5
commit
c4028efd71
@ -9,13 +9,13 @@ export const usePage = (pageId: string) => {
|
|||||||
const { projectPageMap, projectArchivedPageMap } = context.projectPages;
|
const { projectPageMap, projectArchivedPageMap } = context.projectPages;
|
||||||
|
|
||||||
const { projectId, workspaceSlug } = context.app.router;
|
const { projectId, workspaceSlug } = context.app.router;
|
||||||
if (!projectId || !workspaceSlug) throw new Error("usePage must be used within ProjectProvider");
|
if (!projectId || !workspaceSlug) {
|
||||||
|
console.log("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 {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (projectPageMap[projectId] && projectPageMap[projectId][pageId]) return projectPageMap[projectId][pageId];
|
||||||
|
else if (projectArchivedPageMap[projectId] && projectArchivedPageMap[projectId][pageId])
|
||||||
|
return projectArchivedPageMap[projectId][pageId];
|
||||||
|
else return;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user