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