trpc / next-13

experimental playground for tRPC + next.js 13

Home Page:https://rsc.trpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maybe we wanna use `use()`

KATT opened this issue · comments

Maybe we want to do

function MyComponent() {
  const post = use(trpc.post.byId({ id: "1"}))
  // [...]

In order to enable parallelization and using Promise.all, etc

Maybe we can allow both

function MyComponent() {
  const post = trpc.post.byId.use({ id: "1"})
  // [...]

and

function MyComponent() {
  const posts = use(Promise.all([trpc.post.byId({ id: "1"}), trpc.post.byId({ id: "2"})])
  // [...]

Between suspense and error boundaries, would these effectively achieve the same thing?

function MyComponent() {
   const posts = [trpc.post.byId.use({id: "1"}), trpc.post.byId.use({id: "2"})]
   // [...]
}
function MyComponent() {
   const posts = [use(trpc.post.byId({id: "1"})), use(trpc.post.byId({id: "2"})]
   // [...]
}

Between suspense and error boundaries, would these effectively achieve the same thing?

Yes, AFAICT

Dumb question but I can't seem to find the docs for use, is react source code the only documentation for now? I kinda now what it does but it'd be nice to have a spec, a link would be much appreciated