refactor(runtime-core): revert setup() result reactive conversion
BREAKING CHANGE: revert setup() result reactive conversion
Revert 6b10f0c & a840e7d. The motivation of the original change was
avoiding unnecessary deep conversions, but that can be achieved by
explicitly marking values non-reactive via `markNonReactive`.
Removing the reactive conversion behavior leads to an usability
issue in that plain objects containing refs (which is what most
composition functions will return), when exposed as a nested
property from `setup()`, will not unwrap the refs in templates. This
goes against the "no .value in template" intuition and the only
workaround requires users to manually wrap it again with `reactive()`.
So in this commit we are reverting to the previous behavior where
objects returned from `setup()` are implicitly wrapped with
`reactive()` for deep ref unwrapping.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { VNode, VNodeChild, isVNode } from './vnode'
|
||||
import {
|
||||
reactive,
|
||||
ReactiveEffect,
|
||||
shallowReadonly,
|
||||
pauseTracking,
|
||||
@@ -398,7 +399,7 @@ export function handleSetupResult(
|
||||
}
|
||||
// setup returned bindings.
|
||||
// assuming a render function compiled from template is present.
|
||||
instance.renderContext = setupResult
|
||||
instance.renderContext = reactive(setupResult)
|
||||
} else if (__DEV__ && setupResult !== undefined) {
|
||||
warn(
|
||||
`setup() should return an object. Received: ${
|
||||
@@ -474,10 +475,6 @@ function finishComponentSetup(
|
||||
currentInstance = null
|
||||
currentSuspense = null
|
||||
}
|
||||
|
||||
if (instance.renderContext === EMPTY_OBJ) {
|
||||
instance.renderContext = {}
|
||||
}
|
||||
}
|
||||
|
||||
// used to identify a setup context proxy
|
||||
|
||||
Reference in New Issue
Block a user