Skip to content

Commit

Permalink
fix(server-renderer): simplify logic, remove two promises
Browse files Browse the repository at this point in the history
  • Loading branch information
deleteme committed Aug 20, 2024
1 parent 7af4f77 commit e159b16
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/server-renderer/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ export function renderComponentVNode(
const hasAsyncSetup = isPromise(res)
let prefetches = instance.sp /* LifecycleHooks.SERVER_PREFETCH */
if (hasAsyncSetup || prefetches) {
let p: Promise<unknown> = (
hasAsyncSetup
? // instance.sp may be null until an async setup resolves, so evaluate it here
(res as Promise<void>).then(() => (prefetches = instance.sp))
: Promise.resolve()
)
const p: Promise<unknown> = Promise.resolve(res as Promise<void>)
.then(() => {
// instance.sp may be null until an async setup resolves, so evaluate it here
prefetches = instance.sp
if (prefetches) {
return Promise.all(
prefetches.map(prefetch => prefetch.call(instance.proxy)),
Expand Down

0 comments on commit e159b16

Please sign in to comment.