Skip to content

[Vue warn]: Property undefined was accessed during render but is not defined on instance. #2910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runtime-core/__tests__/componentProxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ describe('component: proxy', () => {
`Property ${JSON.stringify(
Symbol.unscopables
)} was accessed during render ` + `but is not defined on instance.`
).toHaveBeenWarned()
).not.toHaveBeenWarned()
})
})
8 changes: 7 additions & 1 deletion packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export interface ComponentRenderContext {
}

export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get({ _: instance }: ComponentRenderContext, key: string) {
get({ _: instance }: ComponentRenderContext, keyOrSymbol: string | symbol) {
const {
ctx,
setupState,
Expand All @@ -251,12 +251,18 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
type,
appContext
} = instance
const key = keyOrSymbol as string

// let @vue/reactivity know it should never observe Vue public instances.
if (key === ReactiveFlags.SKIP) {
return true
}

// this seems to come from the `with(_ctx) {}` used in render functions
if (keyOrSymbol === Symbol.unscopables) {
return undefined
}

// for internal formatters to know that this is a Vue instance
if (__DEV__ && key === '__isVue') {
return true
Expand Down