From 93744d5889216ae1681a5d65cf9d8f7b720d8212 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 28 Feb 2019 12:50:18 -0500 Subject: [PATCH] dx: warn use of reserved methods in render --- packages/runtime-core/src/componentProxy.ts | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index b5855409..1747631d 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -37,16 +37,18 @@ const renderProxyHandlers = { // computed return i[key]() } else if (key[0] !== '_') { - if ( - __DEV__ && - isRendering && - !(key in target) && - !(key in reservedMethods) - ) { - warn( - `property "${key}" was accessed during render but does not exist ` + - `on instance.` - ) + if (__DEV__ && isRendering) { + if (key in reservedMethods) { + warn( + `"${key}" is a reserved method / lifecycle hook and should not be ` + + `used as a normal method during render.` + ) + } else if (!(key in target)) { + warn( + `property "${key}" was accessed during render but does not exist ` + + `on instance.` + ) + } } const value = Reflect.get(target, key, receiver) if (key !== 'constructor' && isFunction(value)) {