From 5c505a43f9b036fea76d2f1925bbe9ba939d1dff Mon Sep 17 00:00:00 2001 From: Leonardo Montini Date: Wed, 13 Aug 2025 14:53:37 +0200 Subject: [PATCH] fix: counters in the homepage no longer disappear on first load --- src/routes/_libraries/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/routes/_libraries/index.tsx b/src/routes/_libraries/index.tsx index fc92206c7..588cd26d5 100644 --- a/src/routes/_libraries/index.tsx +++ b/src/routes/_libraries/index.tsx @@ -1,4 +1,6 @@ import { Await, Link, MatchRoute, getRouteApi } from '@tanstack/react-router' +import { convexQuery } from '@convex-dev/react-query' +import { api } from 'convex/_generated/api' import { twMerge } from 'tailwind-merge' import { CgSpinner } from 'react-icons/cg' import { Footer } from '~/components/Footer' @@ -39,7 +41,20 @@ const courses = [ ] export const Route = createFileRoute({ - loader: () => { + loader: async ({ context: { queryClient } }) => { + const githubQuery = queryClient.ensureQueryData( + convexQuery(api.stats.getGithubOwner, { + owner: 'tanstack', + }) + ) + const npmQuery = queryClient.ensureQueryData( + convexQuery(api.stats.getNpmOrg, { + name: 'tanstack', + }) + ) + + await Promise.all([githubQuery, npmQuery]) + return { randomNumber: Math.random(), }