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

feat(react-query): Add trpc.useSuspenseQueries() #5226

Merged
merged 5 commits into from Dec 26, 2023

Conversation

sachinahya
Copy link
Contributor

Closes #4454

🎯 Changes

Works just like useQueries but supports Suspense. Like useSuspenseQuery returns a [data, queries] tuple of the results for easier renaming and iteration over the results.

Essentially a thin wrapper around the useSuspenseQueries hook added in TanStack Query v5.

const appRouter = t.router({
  foo: t.procedure.query(() => 'foo' as const),
  bar: t.procedure.query(() => 'bar' as const),
});

const [posts, postQueries] = client.useSuspenseQueries((t) => [t.foo(), t.bar() ]);
      // ^? ["foo", "bar"]

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@sachinahya sachinahya requested review from a team as code owners December 26, 2023 21:23
Copy link

vercel bot commented Dec 26, 2023

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

Name Status Preview Comments Updated (UTC)
trpc-next-app-dir ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 26, 2023 9:28pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 26, 2023 9:28pm

Copy link

vercel bot commented Dec 26, 2023

@sachinahya is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

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

Wow, this is brilliant!! THANK YOU! ❤️ ❤️

@KATT KATT merged commit 7d79424 into trpc:next Dec 26, 2023
36 of 41 checks passed
@sachinahya sachinahya deleted the use-suspense-queries branch December 27, 2023 09:29
Copy link

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants