fix: KeepAlive state should be non-reactive

This commit is contained in:
Evan You 2018-10-18 17:49:11 -04:00
parent 05fcfa0782
commit a428218c64

View File

@ -18,8 +18,13 @@ type Cache = Map<CacheKey, VNode>
export const KeepAliveSymbol = Symbol() export const KeepAliveSymbol = Symbol()
export class KeepAlive extends Component<KeepAliveProps> { export class KeepAlive extends Component<KeepAliveProps> {
cache: Cache = new Map() private cache: Cache
keys: Set<CacheKey> = new Set() private keys: Set<CacheKey>
created() {
this.cache = new Map()
this.keys = new Set()
}
// to be set in createRenderer when instance is created // to be set in createRenderer when instance is created
$unmount: (instance: ComponentInstance) => void $unmount: (instance: ComponentInstance) => void
@ -63,9 +68,6 @@ export class KeepAlive extends Component<KeepAliveProps> {
} }
return children return children
} else if ((vnode.flags & VNodeFlags.COMPONENT_STATEFUL) === 0) { } else if ((vnode.flags & VNodeFlags.COMPONENT_STATEFUL) === 0) {
if (__DEV__) {
warn(`KeepAlive child must be a stateful component.`)
}
return children return children
} }