From a12286cdafa2afe69fdaea2e040b6521008baf0f Mon Sep 17 00:00:00 2001 From: ejmg Date: Thu, 11 Jul 2024 14:34:27 -0500 Subject: [PATCH] small fixes to query key, default exports --- src/app/blocks/page.tsx | 5 +++-- src/app/transactions/page.tsx | 2 +- src/components/BlocksTable/index.tsx | 4 +--- src/components/Providers/index.tsx | 1 - src/components/TransactionsTable/index.tsx | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/blocks/page.tsx b/src/app/blocks/page.tsx index ca87b76..c526f1c 100644 --- a/src/app/blocks/page.tsx +++ b/src/app/blocks/page.tsx @@ -1,4 +1,4 @@ -import BlocksTable from "@/components/BlocksTable"; +import { BlocksTable } from "@/components/BlocksTable"; import getBlocks from "@/components/BlocksTable/getBlocks"; import { HydrationBoundary, QueryClient, dehydrate } from "@tanstack/react-query"; @@ -11,13 +11,14 @@ const Page = () => { pageIndex: 0, pageSize: 10, }; + const queryName = "BlocksTable"; const endpoint = "/api/blocks"; const errorMessage = "Failed to query data while trying to generate blocks table, please try reloading the page."; queryClient.prefetchQuery({ queryFn: () => getBlocks({ endpoint, pageIndex: 0}), - queryKey: [queryName, defaultQueryOptions], + queryKey: [queryName, defaultQueryOptions.pageIndex], meta: { errorMessage, }, diff --git a/src/app/transactions/page.tsx b/src/app/transactions/page.tsx index 155aa99..24c5dc1 100644 --- a/src/app/transactions/page.tsx +++ b/src/app/transactions/page.tsx @@ -19,7 +19,7 @@ const Page = () => { queryClient.prefetchQuery({ queryFn: () => getTransactions({ endpoint, pageIndex: 0}), - queryKey: [queryName, defaultQueryOptions], + queryKey: [queryName, defaultQueryOptions.pageIndex], meta: { errorMessage, }, diff --git a/src/components/BlocksTable/index.tsx b/src/components/BlocksTable/index.tsx index 7f2d273..8c4ff7a 100644 --- a/src/components/BlocksTable/index.tsx +++ b/src/components/BlocksTable/index.tsx @@ -33,7 +33,7 @@ export function BlocksTable ({ const [pagination, setPagination] = useState({...defaultQueryOptions}); const { data } = useSuspenseQuery({ - queryKey: [queryName, pagination], + queryKey: [queryName, pagination.pageIndex], queryFn: () => getBlocks({ endpoint, pageIndex: pagination.pageIndex }), meta: { errorMessage, @@ -60,5 +60,3 @@ export function BlocksTable ({ ); }; - -export default BlocksTable; diff --git a/src/components/Providers/index.tsx b/src/components/Providers/index.tsx index 53ee003..9f16541 100644 --- a/src/components/Providers/index.tsx +++ b/src/components/Providers/index.tsx @@ -26,7 +26,6 @@ const makeQueryClient = () => { queries: { // Direct suggestion by tanstack, to prevent over-eager refetching from the client. staleTime: 60 * 1000, - refetchOnWindowFocus: false, }, dehydrate: { // only successful and pending Queries are included per defaults diff --git a/src/components/TransactionsTable/index.tsx b/src/components/TransactionsTable/index.tsx index 2c57b2c..e7d4f88 100644 --- a/src/components/TransactionsTable/index.tsx +++ b/src/components/TransactionsTable/index.tsx @@ -32,7 +32,7 @@ export function TransactionsTable ({ const [pagination, setPagination] = useState({...defaultQueryOptions}); const { data } = useSuspenseQuery({ - queryKey: [queryName, pagination], + queryKey: [queryName, pagination.pageIndex], queryFn: () => getTransactions({ endpoint, pageIndex: pagination.pageIndex }), meta: { errorMessage,