@@ -288,7 +288,6 @@ function setupStatefulComponent(
288
288
instance : ComponentInternalInstance ,
289
289
parentSuspense : SuspenseBoundary | null
290
290
) {
291
- let setupResult
292
291
const Component = instance . type as ComponentOptions
293
292
294
293
if ( __DEV__ ) {
@@ -315,7 +314,9 @@ function setupStatefulComponent(
315
314
// 2. create props proxy
316
315
// the propsProxy is a reactive AND readonly proxy to the actual props.
317
316
// it will be updated in resolveProps() on updates before render
318
- const propsProxy = ( instance . propsProxy = shallowReadonly ( instance . props ) )
317
+ const propsProxy = ( instance . propsProxy = __SSR__
318
+ ? instance . props
319
+ : shallowReadonly ( instance . props ) )
319
320
// 3. call setup()
320
321
const { setup } = Component
321
322
if ( setup ) {
@@ -324,7 +325,7 @@ function setupStatefulComponent(
324
325
325
326
currentInstance = instance
326
327
currentSuspense = parentSuspense
327
- setupResult = callWithErrorHandling (
328
+ const setupResult = callWithErrorHandling (
328
329
setup ,
329
330
instance ,
330
331
ErrorCodes . SETUP_FUNCTION ,
@@ -334,7 +335,10 @@ function setupStatefulComponent(
334
335
currentSuspense = null
335
336
336
337
if ( isPromise ( setupResult ) ) {
337
- if ( __FEATURE_SUSPENSE__ ) {
338
+ if ( __SSR__ ) {
339
+ // return the promise so server-renderer can wait on it
340
+ return setupResult
341
+ } else if ( __FEATURE_SUSPENSE__ ) {
338
342
// async setup returned Promise.
339
343
// bail here and wait for re-entry.
340
344
instance . asyncDep = setupResult
@@ -350,8 +354,6 @@ function setupStatefulComponent(
350
354
} else {
351
355
finishComponentSetup ( instance , parentSuspense )
352
356
}
353
-
354
- return setupResult
355
357
}
356
358
357
359
export function handleSetupResult (
@@ -371,7 +373,7 @@ export function handleSetupResult(
371
373
}
372
374
// setup returned bindings.
373
375
// assuming a render function compiled from template is present.
374
- instance . renderContext = reactive ( setupResult )
376
+ instance . renderContext = __SSR__ ? setupResult : reactive ( setupResult )
375
377
} else if ( __DEV__ && setupResult !== undefined ) {
376
378
warn (
377
379
`setup() should return an object. Received: ${
@@ -449,7 +451,7 @@ function finishComponentSetup(
449
451
}
450
452
451
453
if ( instance . renderContext === EMPTY_OBJ ) {
452
- instance . renderContext = reactive ( { } )
454
+ instance . renderContext = __SSR__ ? { } : reactive ( { } )
453
455
}
454
456
}
455
457
0 commit comments