Skip to content

Commit

Permalink
Fix admin meta fetching (#4879)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Feb 18, 2021
1 parent 39de79d commit 0e265f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-cooks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/admin-ui': patch
---

Fixed fetching admin meta causing an infinite loop.
9 changes: 9 additions & 0 deletions packages-next/admin-ui/src/utils/useAdminMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ export function useAdminMeta(adminMetaHash: string, fieldViews: FieldViews) {
if (typeof window !== 'undefined' && adminMetaFromLocalStorage === undefined && !called) {
fetchStaticAdminMeta();
}

let shouldFetchAdminMeta = adminMetaFromLocalStorage === undefined && !called;

useEffect(() => {
if (shouldFetchAdminMeta) {
fetchStaticAdminMeta();
}
}, [shouldFetchAdminMeta, fetchStaticAdminMeta]);

const runtimeAdminMeta = useMemo(() => {
if ((!data || error) && !adminMetaFromLocalStorage) {
return undefined;
Expand Down

1 comment on commit 0e265f6

@vercel
Copy link

@vercel vercel bot commented on 0e265f6 Feb 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.