How to check if an object is a Vue component in Vue3?

Viewed 524

With vue 2 I could simply just

import Vue from "vue"

and then do the following

if (!(myComponent instanceof Vue)) return

Is there a way to do it in Vue3?

1 Answers

It is not a very elegant solution but you can check if it has a render function.

if (!(myComponent && typeof myComponent.render  === 'function')) return
Related