Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Update @tanstack/react-query to 5.8.1 (#1075)

__aadamwbded6d41d263
diff --git a/apps/admin/package.json b/apps/admin/package.json
index 5792dbe4..642b199f 100644
--- a/apps/admin/package.json
+++ b/apps/admin/package.json
@@ -22,7 +22,7 @@
"@repo/lint": "workspace:*",
"@repo/monaco": "workspace:*",
"@repo/ui": "workspace:*",
- "@tanstack/react-query": "^4.29.25",
+ "@tanstack/react-query": "^5.8.1",
"@tanstack/react-table": "^8.9.3",
"clsx": "^2.0.0",
"million": "2.6.0-beta.12",
diff --git a/apps/admin/src/app/providers.tsx b/apps/admin/src/app/providers.tsx
index 062f67d8..acc8a142 100644
--- a/apps/admin/src/app/providers.tsx
+++ b/apps/admin/src/app/providers.tsx
@@ -12,7 +12,7 @@ interface Props {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
- cacheTime: 0,
+ gcTime: 0,
},
},
});
diff --git a/apps/web/package.json b/apps/web/package.json
index 6e17a448..ab2efb83 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -34,8 +34,8 @@
"@repo/ui": "workspace:*",
"@sentry/nextjs": "^7.73.0",
"@t3-oss/env-nextjs": "^0.6.0",
- "@tanstack/react-query": "^4.29.25",
- "@tanstack/react-query-devtools": "^4.35.3",
+ "@tanstack/react-query": "^5.8.1",
+ "@tanstack/react-query-devtools": "^5.8.1",
"@tanstack/react-table": "^8.9.3",
"@uiw/react-md-editor": "^3.23.3",
"@uploadthing/react": "^5.5.0",
diff --git a/apps/web/src/app/[locale]/(email)/waitlist/_components/waitlist-form.tsx b/apps/web/src/app/[locale]/(email)/waitlist/_components/waitlist-form.tsx
index d4a52578..bd088f9a 100644
--- a/apps/web/src/app/[locale]/(email)/waitlist/_components/waitlist-form.tsx
+++ b/apps/web/src/app/[locale]/(email)/waitlist/_components/waitlist-form.tsx
@@ -136,11 +136,11 @@ export function WaitlistForm() {
<Button
className="wl-form-button group relative mt-6 w-full overflow-hidden rounded-xl px-[2px] py-[2px] font-bold transition-shadow duration-300 hover:shadow-[0_0.5rem_2rem_-0.75rem_#3178c6] dark:hover:shadow-[0_0.5rem_2rem_-0.75rem_#5198f6]"
- disabled={mutation.status === 'loading'}
+ disabled={mutation.status === 'pending'}
type="submit"
>
<span className="h-full w-full rounded-[10px] bg-white px-4 py-2 text-center font-bold text-black transition-colors duration-300 group-hover:bg-blue-100 dark:bg-black dark:text-white group-hover:dark:bg-cyan-950">
- {mutation.status === 'loading' ? 'Submitting...' : 'Join the waitlist'}
+ {mutation.status === 'pending' ? 'Submitting...' : 'Join the waitlist'}
</span>
</Button>
</form>
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/index.tsx b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/index.tsx
index a63c4f8e..879d4f90 100644
--- a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/index.tsx
@@ -69,7 +69,6 @@ export function Solutions({ slug }: Props) {
queryKey,
queryFn: () =>
getPaginatedSolutions({ slug, page, sortKey: sortKey.key, sortOrder: sortKey.order }),
- keepPreviousData: true,
staleTime: 60000, // one minute
refetchOnWindowFocus: false,
});
@@ -90,7 +89,7 @@ export function Solutions({ slug }: Props) {
<>
{pageData?.sharedSolution?.length !== 0 ? (
<>
- {status === 'loading' && <SolutionsSkeleton />}
+ {status === 'pending' && <SolutionsSkeleton />}
{status === 'success' && (
<div className="bg-background/70 dark:bg-muted/70 flex w-full justify-end border-b border-zinc-300 p-2 backdrop-blur-sm dark:border-zinc-700">
<SubmitSolution disabled={Boolean(!loggedInUserHasSolution)} setView={setView} />
diff --git a/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx b/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
index 185d166b..dd5ff3c7 100644
--- a/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
@@ -24,7 +24,7 @@ interface Props {
export function ChallengeTrackNavigation({ challenge, track, isCollapsed, className }: Props) {
const router = useRouter();
- const { data: trackDetails, isLoading } = useQuery({
+ const { data: trackDetails, isPending } = useQuery({
queryKey: ['track-details', track?.slug],
queryFn: () => {
return getTrackDetails(track!.slug);
@@ -55,7 +55,7 @@ export function ChallengeTrackNavigation({ challenge, track, isCollapsed, classN
return index > 0 ? trackDetails!.trackChallenges[index] : null;
}, [currentIndex, trackDetails]);
- if (isLoading || track === null || trackDetails === null || trackDetails === undefined)
+ if (isPending || track === null || trackDetails === null || trackDetails === undefined)
return null;
return (
diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
index b20212f0..3e36b3f5 100644
--- a/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
@@ -106,7 +106,7 @@ export function Comment({
const {
data: replies,
fetchStatus,
- isLoading: isLoadingReplies,
+ isPending: isLoadingReplies,
} = useQuery({
queryKey: replyQueryKey,
queryFn: () => getAllComments({ rootId, rootType: type, parentId: comment.id }),
@@ -121,8 +121,9 @@ export function Comment({
hasNextPage: hasMoreReplies,
refetch,
} = useInfiniteQuery({
+ initialPageParam: 0,
queryKey: [...replyQueryKey, 'paginated'],
- queryFn: ({ pageParam = 0 }) => {
+ queryFn: ({ pageParam }) => {
// `cursor` is the start index of the current page
const cursor = Number(pageParam);
@@ -173,8 +174,8 @@ export function Comment({
});
}
setReplyText('');
- queryClient.invalidateQueries(replyQueryKey);
- queryClient.invalidateQueries(queryKey);
+ queryClient.invalidateQueries({ queryKey: replyQueryKey });
+ queryClient.invalidateQueries({ queryKey });
setShowReplies(true);
} catch (e) {
toast({
@@ -291,8 +292,8 @@ function SingleComment({
description: <p>You need to be signed in to post a comment.</p>,
});
}
- queryClient.invalidateQueries(queryKey);
- queryClient.invalidateQueries(replyQueryKey);
+ queryClient.invalidateQueries({ queryKey });
+ queryClient.invalidateQueries({ queryKey: replyQueryKey });
} catch (e) {
toast({
title: 'Unauthorized',
diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/delete/index.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/delete/index.tsx
index cb7c37e7..436c4747 100644
--- a/apps/web/src/app/[locale]/challenge/_components/comments/delete/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/comments/delete/index.tsx
@@ -55,7 +55,7 @@ export function CommentDeleteDialog({
description: 'An error occurred while trying to delete the comment.',
});
} finally {
- queryClient.invalidateQueries(queryKey);
+ queryClient.invalidateQueries({ queryKey });
setIsOpen(!isOpen);
}
}
diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/index.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/index.tsx
index 29c790bb..8d341a05 100644
--- a/apps/web/src/app/[locale]/challenge/_components/comments/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/comments/index.tsx
@@ -68,7 +68,6 @@ export function Comments({ preselectedCommentMetadata, rootId, type, expanded =
sortKey: sortKey.key,
sortOrder: sortKey.order,
}),
- keepPreviousData: true,
staleTime: 60000, // one minute
refetchOnWindowFocus: false,
});
@@ -92,7 +91,7 @@ export function Comments({ preselectedCommentMetadata, rootId, type, expanded =
});
}
setText('');
- queryClient.invalidateQueries([`${type.toLowerCase()}-${rootId}-comments`]);
+ queryClient.invalidateQueries({ queryKey: [`${type.toLowerCase()}-${rootId}-comments`] });
} catch (e) {
toast({
title: 'Unauthorized',
@@ -168,7 +167,7 @@ export function Comments({ preselectedCommentMetadata, rootId, type, expanded =
onValueChange={handleValueChange}
/>
)}
- {status === 'loading' && <CommentSkeleton />}
+ {status === 'pending' && <CommentSkeleton />}
<div className="flex-1">
{status === 'success' &&
(data.comments.length === 0 ? (
diff --git a/apps/web/src/app/[locale]/providers.tsx b/apps/web/src/app/[locale]/providers.tsx
index 5e434201..6e21c6aa 100644
--- a/apps/web/src/app/[locale]/providers.tsx
+++ b/apps/web/src/app/[locale]/providers.tsx
@@ -9,7 +9,6 @@ import React, { Suspense } from 'react';
import { Toolbar } from '~/components/toolbar';
import { I18nProviderClient } from '~/locales/client';
import { FeatureFlagProvider } from '../feature-flag-provider';
-import type { Corner } from '@tanstack/react-query-devtools/build/lib/utils';
interface Props {
children: React.ReactNode;
@@ -18,10 +17,9 @@ interface Props {
const queryClient = new QueryClient();
export function Providers({ children }: Props) {
- const position: Corner = 'bottom-right';
return (
<QueryClientProvider client={queryClient}>
- <ReactQueryDevtools initialIsOpen={false} position={position} />
+ <ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-right" />
<SessionProvider>
<ThemeProvider attribute="class">
<FeatureFlagProvider>
diff --git a/apps/web/src/app/feature-flag-provider.tsx b/apps/web/src/app/feature-flag-provider.tsx
index b91e715a..b6fef412 100644
--- a/apps/web/src/app/feature-flag-provider.tsx
+++ b/apps/web/src/app/feature-flag-provider.tsx
@@ -10,7 +10,10 @@ interface Props {
const isProd = process.env.NODE_ENV === 'production';
export function FeatureFlagProvider({ children }: Props) {
- const { data: featureFlags } = useQuery(['featureFlags'], () => getFeatureFlags());
+ const { data: featureFlags } = useQuery({
+ queryKey: ['featureFlags'],
+ queryFn: () => getFeatureFlags(),
+ });
return <FeatureFlagContext.Provider value={featureFlags}>{children}</FeatureFlagContext.Provider>;
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9e98eba8..9e992111 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -80,8 +80,8 @@ importers:
specifier: workspace:*
version: link:../../packages/ui
'@tanstack/react-query':
- specifier: ^4.29.25
+ specifier: ^5.8.1
'@tanstack/react-table':
specifier: ^8.9.3
@@ -268,11 +268,11 @@ importers:
specifier: ^0.6.0
'@tanstack/react-query':
- specifier: ^4.29.25
+ specifier: ^5.8.1
'@tanstack/react-query-devtools':
- specifier: ^4.35.3
+ specifier: ^5.8.1
'@tanstack/react-table':
specifier: ^8.9.3
@@ -730,7 +730,7 @@ importers:
dependencies:
'@next/eslint-plugin-next':
specifier: canary
- version: 13.4.20-canary.0
+ version: 14.0.2-canary.21
'@repo/tsconfig':
specifier: workspace:*
version: link:../config-typescript
@@ -742,7 +742,7 @@ importers:
'@vercel/style-guide':
specifier: ^4.0.2
eslint:
specifier: ^8.45.0
version: 8.45.0
@@ -2331,8 +2331,8 @@ packages:
glob: 7.1.7
dev: true
- resolution: {integrity: sha512-vFC1meiw/awh2xJZMWaoECsfZbgkt2fF3HIg8f2fSM/w41Z86L1SS7SjKmpbbD87yq3tiqgqHmFv0JCych4g4g==}
+ resolution: {integrity: sha512-ztXdwdEdW7mLU7QCiU4huIMQNQfnKw0vuGLDjSJXetiPdp+SdfViHH5RuTB+/CUvAbNUonqeuV0gP1BPRf6JLg==}
dependencies:
glob: 7.1.7
dev: false
@@ -4523,37 +4523,32 @@ packages:
tailwindcss: 3.3.3
dev: true
- /@tanstack/[email protected]:
- resolution: {integrity: sha512-rKH8LjZiszWEvmi01NR72QWZ8m4xmXre0OOwlRGnjU01Eqz/QnN+cqpty2PJ0efHblq09+KilvyR7lsbzmXVEw==}
- engines: {node: '>=12'}
- dependencies:
- remove-accents: 0.4.2
+ /@tanstack/[email protected]:
+ resolution: {integrity: sha512-Y0enatz2zQXBAsd7XmajlCs+WaitdR7dIFkqz9Xd7HL4KV04JOigWVreYseTmNH7YFSBSC/BJ9uuNp1MAf+GfA==}
dev: false
- /@tanstack/[email protected]:
- resolution: {integrity: sha512-DI4y4VC6Uw4wlTpOocEXDky69xeOScME1ezLKsj+hOk7DguC9fkqXtp6Hn39BVb9y0b5IBrY67q6kIX623Zj4Q==}
+ /@tanstack/[email protected]:
+ resolution: {integrity: sha512-wx+gwRZUZq7ISXKFJgaAYvVPt+DwTaLKlzaVLB9SLBFIzcL8Jz8jDQGR9ZQp7/O7SVj0TohS8aFuiiGzQUvWyg==}
dev: false
- resolution: {integrity: sha512-UvLT7qPzCuCZ3NfjwsOqDUVN84JvSOuW6ukrjZmSqgjPqVxD6ra/HUp1CEOatQY2TRvKCp8y1lTVu+trXM30fg==}
+ resolution: {integrity: sha512-sE6El2Yj98LlPDzf2Ju9IjWPZvqh2RgoQZ+Jomrfm80uA1HlHUvhXuOB0mOcyc706ZpNpL54no59JbgpHcMuUg==}
peerDependencies:
- '@tanstack/react-query': ^4.35.3
- react: ^16.8.0 || ^17.0.0 || ^18.0.0
- react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ '@tanstack/react-query': ^5.8.1
+ react: ^18.0.0
+ react-dom: ^18.0.0
dependencies:
- '@tanstack/match-sorter-utils': 8.8.4
- '@tanstack/react-query': 4.29.25([email protected])([email protected])
+ '@tanstack/query-devtools': 5.7.4
+ '@tanstack/react-query': 5.8.1([email protected])([email protected])
react: 18.2.0
react-dom: 18.2.0([email protected])
- superjson: 1.12.4
- use-sync-external-store: 1.2.0([email protected])
dev: false
- resolution: {integrity: sha512-c1+Ezu+XboYrdAMdusK2fTdRqXPMgPAnyoTrzHOZQqr8Hqz6PNvV9DSKl8agUo6nXX4np7fdWabIprt+838dLg==}
+ resolution: {integrity: sha512-YMagxS8iNPOLg0pK6WOjdSDlAvWKOf69udLOwQrBVmkC2SRLNLko7elo5Ro3ptlJkXvTVHidxC/h5KGi5bH1XQ==}
peerDependencies:
- react: ^16.8.0 || ^17.0.0 || ^18.0.0
- react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^18.0.0
+ react-dom: ^18.0.0
react-native: '*'
peerDependenciesMeta:
react-dom:
@@ -4561,10 +4556,9 @@ packages:
react-native:
optional: true
dependencies:
- '@tanstack/query-core': 4.29.25
+ '@tanstack/query-core': 5.8.1
react: 18.2.0
react-dom: 18.2.0([email protected])
- use-sync-external-store: 1.2.0([email protected])
dev: false
@@ -5142,7 +5136,7 @@ packages:
yoga-wasm-web: 0.3.0
dev: false
resolution: {integrity: sha512-FroL+oOePzhw7n/I+f7zr4WNroGHT/+2TlW6WH9+CVSjMNsEyu7Qstj2mI5gWIBjT1Y2ZImKPppCzI2cIYmNZw==}
engines: {node: '>=16'}
peerDependencies:
@@ -5162,7 +5156,7 @@ packages:
dependencies:
'@babel/core': 7.22.10
'@babel/eslint-parser': 7.22.10(@babel/[email protected])([email protected])
- '@next/eslint-plugin-next': 13.4.20-canary.0
+ '@next/eslint-plugin-next': 14.0.2-canary.21
'@rushstack/eslint-patch': 1.3.2
'@typescript-eslint/eslint-plugin': 5.59.1(@typescript-eslint/[email protected])([email protected])([email protected])
'@typescript-eslint/parser': 5.62.0([email protected])([email protected])
@@ -11152,10 +11146,6 @@ packages:
unified: 10.1.2
dev: false
- resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==}
- dev: false
-
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
engines: {node: '>=0.10'}