feat: warn missing render() function
This commit is contained in:
parent
7d091b5e91
commit
2f936a0dfe
@ -13,6 +13,7 @@ import { nextTick } from '@vue/scheduler'
|
|||||||
import { ErrorTypes } from './errorHandling'
|
import { ErrorTypes } from './errorHandling'
|
||||||
import { initializeComponentInstance } from './componentUtils'
|
import { initializeComponentInstance } from './componentUtils'
|
||||||
import { EventEmitter, invokeListeners } from './optional/eventEmitter'
|
import { EventEmitter, invokeListeners } from './optional/eventEmitter'
|
||||||
|
import { warn } from './warning'
|
||||||
|
|
||||||
// public component instance type
|
// public component instance type
|
||||||
export interface Component<P = {}, D = {}> extends PublicInstanceMethods {
|
export interface Component<P = {}, D = {}> extends PublicInstanceMethods {
|
||||||
@ -150,6 +151,15 @@ class InternalComponent implements PublicInstanceMethods {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// necessary to tell this apart from a functional
|
||||||
|
render(...args: any[]): any {
|
||||||
|
if (__DEV__) {
|
||||||
|
const name =
|
||||||
|
(this.$options && this.$options.displayName) || this.constructor.name
|
||||||
|
warn(`Class component \`${name}\` is missing render() method.`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// to be set by renderer during mount
|
// to be set by renderer during mount
|
||||||
$forceUpdate: () => void = NOOP
|
$forceUpdate: () => void = NOOP
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ const renderProxyHandlers = {
|
|||||||
// TODO warn non-present property
|
// TODO warn non-present property
|
||||||
}
|
}
|
||||||
const value = Reflect.get(target, key, receiver)
|
const value = Reflect.get(target, key, receiver)
|
||||||
if (isFunction(value)) {
|
if (key !== 'constructor' && isFunction(value)) {
|
||||||
// auto bind
|
// auto bind
|
||||||
return getBoundMethod(value, target, receiver)
|
return getBoundMethod(value, target, receiver)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user