From a14157696e2b5c9ab399cb219c87b9562498f8eb Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Mon, 19 Aug 2024 15:38:30 +0200 Subject: [PATCH] fix: remove initialData to avoid page load issues --- .../Points/EarnAndBurn/JourneyTable/Client.tsx | 16 +++++----------- .../Points/EarnAndBurn/JourneyTable/index.tsx | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx index e4905270f..ab286c9db 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx @@ -1,6 +1,7 @@ "use client" -import { useEffect, useState } from "react" +import { keepPreviousData } from "@tanstack/react-query" +import { useState } from "react" import { trpc } from "@/lib/trpc/client" @@ -93,9 +94,6 @@ export default function TransactionTable({ }) { const limit = 5 const [page, setPage] = useState(1) - // const [currentTransactions, setCurrentTransactions] = useState( - // [] - // ) const { data, isFetching, isLoading } = trpc.user.transaction.friendTransactions.useQuery( { @@ -103,16 +101,12 @@ export default function TransactionTable({ page, }, { - initialData: initialJourneyTransactions, + // TODO: fix the initial data issues on page load + // initialData: initialJourneyTransactions, + placeholderData: keepPreviousData, } ) - // useEffect(() => { - // if (data?.data.transactions) { - // setCurrentTransactions(data.data.transactions) - // } - // }, [data?.data.transactions]) - // const totalPages = data?.meta.totalPages || 0 return isLoading ? ( ) : ( diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/index.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/index.tsx index 1a7922669..08acf2e1d 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/index.tsx +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/index.tsx @@ -8,7 +8,7 @@ export default async function JourneyTable() { page: 1, limit: 5, }) - if (!initialJourneyTransactions?.data.transactions.length) { + if (!initialJourneyTransactions?.data) { return null }