Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trpc/react-query — only one query client should exist #18179

Merged
merged 7 commits into from
Dec 14, 2024

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Dec 13, 2024

What does this PR do?

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@graphite-app graphite-app bot requested a review from a team December 13, 2024 22:45
@dosubot dosubot bot added the 🐛 bug Something isn't working label Dec 13, 2024
@keithwillcode keithwillcode added consumer core area: core, team members only labels Dec 13, 2024
@hbjORbj hbjORbj marked this pull request as draft December 13, 2024 22:46
Copy link

vercel bot commented Dec 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Dec 14, 2024 0:47am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Dec 14, 2024 0:47am

Copy link

graphite-app bot commented Dec 13, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (12/13/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@hbjORbj hbjORbj changed the title fix: incorrect configs in trpc provider caused query caching issues fix: trpc/react-query — one query client should be used Dec 13, 2024
@hbjORbj hbjORbj marked this pull request as ready for review December 13, 2024 23:53
@hbjORbj hbjORbj changed the title fix: trpc/react-query — one query client should be used fix: trpc/react-query — only one query client should exist Dec 13, 2024
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: { queries: { staleTime: 5000 } },
// these configurations are copied from "packages/trpc/react/trpc.ts"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the comment says

@@ -1,11 +1,16 @@
import { type DehydratedState, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { HydrateClient } from "app/_trpc/HydrateClient";
"use client";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a client component. we use useState.

@@ -112,7 +113,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
}}
/>
)}
{children}
<TrpcProvider>{children}</TrpcProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call this provider only once and hence it needs to be in this file

Copy link
Contributor

github-actions bot commented Dec 14, 2024

E2E results are ready!

Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 nice find!

@emrysal emrysal disabled auto-merge December 14, 2024 00:48
@hbjORbj hbjORbj merged commit f72748b into main Dec 14, 2024
39 checks passed
@hbjORbj hbjORbj deleted the fix/trpc-app-router branch December 14, 2024 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working consumer core area: core, team members only ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants