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

[Vue warn]: Error in render: "TypeError: Cannot read property 'template' of null" #1805

Closed
sandro78 opened this issue Mar 9, 2021 · 1 comment · Fixed by #1897
Closed

Comments

@sandro78
Copy link

sandro78 commented Mar 9, 2021

Subject of the issue

Undesired errors at console during tests run:

[Vue warn]: Error in render: "TypeError: Cannot read property 'template' of null"

Steps to reproduce

Was faced with above issue and found place at code which rises it:

function isComponentOptions(c) {
return typeof c === 'object' && (c.template || c.render)
}

In fact typeof null in JS also returns 'object' - have you expected this guys?)))

Expected behaviour

Suggest to change this place in way:

return !!c && typeof c === 'object' && (c.template || c.render)

Actual behaviour

Tons of errors at console like:
[Vue warn]: Error in render: "TypeError: Cannot read property 'template' of null"

Possible Solution

Haven't found workaround yet.

@yang-mengyue
Copy link

我也遇到此问题。是没找到解决方法

ataias added a commit to ataias/vue-test-utils that referenced this issue Aug 19, 2021
Using vue-test-utils may cause several messages of the sort
```
[Vue warn]: Error in render: "TypeError: Cannot read property 'template' of null"
```

Such messages stemmed from the `isComponentOptions` method call. It
seems it received a null object and `typeof null` is object, so this
error propagates to users of the library.

This patch does not look for the reason a null object was sent in the
first place, but it avoids the error propagation.

close vuejs#1805
lmiller1990 pushed a commit that referenced this issue Oct 29, 2021
Using vue-test-utils may cause several messages of the sort
```
[Vue warn]: Error in render: "TypeError: Cannot read property 'template' of null"
```

Such messages stemmed from the `isComponentOptions` method call. It
seems it received a null object and `typeof null` is object, so this
error propagates to users of the library.

This patch does not look for the reason a null object was sent in the
first place, but it avoids the error propagation.

close #1805
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 a pull request may close this issue.

2 participants