Skip to content
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

feat(runtime-core): improve render context warning #2496

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

LinusBorg
Copy link
Member

@LinusBorg LinusBorg commented Oct 27, 2020

Problem

When we try to access a non-existing property on a component during rendering, we get this helpful warning:

Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.

However, the current implementation logs this warning as long as some component is currently rendering. In other words, the warning is not limited to the render cycle of the component instance that we tried to read the property from.

Solution

I think this warning should only be printed out during the component's own render.

Use case:

When reading a property from a child component instance obtained from a template ref, one might not know which kind of component the ref contains, so reading a prop in order to do a sort of duck typing is useful.

But with the current implementation, a warning would be logged to the console each time a child component is checked programmatically like this.

@github-actions
Copy link

Size report

Path Size
vue.global.prod.js 40.15 KB (0%)
runtime-dom.global.prod.js 26.43 KB (0%)
size-check.global.prod.js 15.95 KB (0%)

@LinusBorg LinusBorg requested a review from HcySunYang February 4, 2021 10:21
@LinusBorg LinusBorg merged commit 288ae0a into master Feb 5, 2021
@LinusBorg LinusBorg deleted the >linusborg/improve-render-warning-missing-props branch February 5, 2021 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants