wip(ssr): reduce reactivity overhead during ssr

This commit is contained in:
Evan You
2020-01-24 11:39:52 -05:00
parent cee36ad028
commit 25a0d4a65f
7 changed files with 50 additions and 21 deletions

View File

@@ -36,6 +36,14 @@ export function ref(raw?: unknown) {
return raw
}
raw = convert(raw)
if (__SSR__) {
return {
_isRef: true,
value: raw
}
}
const r = {
_isRef: true,
get value() {
@@ -58,7 +66,7 @@ export function ref(raw?: unknown) {
export function toRefs<T extends object>(
object: T
): { [K in keyof T]: Ref<T[K]> } {
if (__DEV__ && !isReactive(object)) {
if (__DEV__ && !__SSR__ && !isReactive(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`)
}
const ret: any = {}