From d7f92841232c257279106c8eef226ce8ea74ecd0 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 18 Dec 2023 11:38:06 +0100 Subject: fix(pages): do not show spinner when data are available The `useSWR` hook set `isLoading` to `true` on first fetch even if the fallback data is provided. It affects how pages are generated on build: the loading page is showing instead of the actual page. So we need to return a custom `isLoading` variable that checks if there is no data. --- src/utils/hooks/use-comments/use-comments.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils/hooks/use-comments/use-comments.ts') diff --git a/src/utils/hooks/use-comments/use-comments.ts b/src/utils/hooks/use-comments/use-comments.ts index cb967a5..7c8f11e 100644 --- a/src/utils/hooks/use-comments/use-comments.ts +++ b/src/utils/hooks/use-comments/use-comments.ts @@ -36,7 +36,7 @@ export const useComments = >({ ? buildCommentsTree(data.map(convertWPCommentToComment)) : undefined, isError: !!error, - isLoading, + isLoading: isLoading && !data, isValidating, } as UseCommentsReturn; }; -- cgit v1.2.3