Skip to content

Commit

Permalink
RSC: Add comment explaining use() (#10411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Apr 4, 2024
1 parent 6cc5949 commit 6ff2e3e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,18 @@ export function renderFromRscServer<TProps>(rscId: string) {
}
}

// TODO (RSC): Might be an issue here with startTransition according to the
// waku sources I copied this from. We need to figure out if this is the
// right way to do things
// `use()` will throw a `SuspenseException` as long as `dataToReturn` is
// unfulfilled. React internally tracks this promise and re-renders this
// component when the promise resolves. When the promise is resolved no
// exception will be thrown and the actual value of the promise will be
// returned instead
// The closest suspense boundary will render its fallback when the
// exception is thrown
return use(dataToReturn)

// TODO (RSC): Might be an issue with `use` above with startTransition
// according to the waku sources I copied this from. We need to figure out
// if this is the right way to do things
}

return ServerComponent
Expand Down

0 comments on commit 6ff2e3e

Please sign in to comment.