dx: warn use of reserved methods in render

This commit is contained in:
Evan You 2019-02-28 12:50:18 -05:00
parent 3754233f38
commit 93744d5889

View File

@ -37,17 +37,19 @@ const renderProxyHandlers = {
// computed // computed
return i[key]() return i[key]()
} else if (key[0] !== '_') { } else if (key[0] !== '_') {
if ( if (__DEV__ && isRendering) {
__DEV__ && if (key in reservedMethods) {
isRendering && warn(
!(key in target) && `"${key}" is a reserved method / lifecycle hook and should not be ` +
!(key in reservedMethods) `used as a normal method during render.`
) { )
} else if (!(key in target)) {
warn( warn(
`property "${key}" was accessed during render but does not exist ` + `property "${key}" was accessed during render but does not exist ` +
`on instance.` `on instance.`
) )
} }
}
const value = Reflect.get(target, key, receiver) const value = Reflect.get(target, key, receiver)
if (key !== 'constructor' && isFunction(value)) { if (key !== 'constructor' && isFunction(value)) {
// auto bind // auto bind