Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e159b16

Browse files
committed
fix(server-renderer): simplify logic, remove two promises
1 parent 7af4f77 commit e159b16

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

‎packages/server-renderer/src/render.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,10 @@ export function renderComponentVNode(
9696
const hasAsyncSetup = isPromise(res)
9797
let prefetches = instance.sp /* LifecycleHooks.SERVER_PREFETCH */
9898
if (hasAsyncSetup || prefetches) {
99-
let p: Promise<unknown> = (
100-
hasAsyncSetup
101-
? // instance.sp may be null until an async setup resolves, so evaluate it here
102-
(res as Promise<void>).then(() => (prefetches = instance.sp))
103-
: Promise.resolve()
104-
)
99+
const p: Promise<unknown> = Promise.resolve(res as Promise<void>)
105100
.then(() => {
101+
// instance.sp may be null until an async setup resolves, so evaluate it here
102+
prefetches = instance.sp
106103
if (prefetches) {
107104
return Promise.all(
108105
prefetches.map(prefetch => prefetch.call(instance.proxy)),

0 commit comments

Comments
 (0)