Class-based TypeScript component does not get initialized properly
See original GitHub issueHi there!
I am trying to run a minimal configuration using vue-custom-element and TypeScript. Unfortunately, I get this error when trying to load the html file in a browser:
vue.esm.js?a026:4798 Uncaught TypeError: Cannot read property '_init' of undefined
at VueComponent (vue.esm.js?a026:4798)
at HTMLElement.connectedCallback (vue-custom-element.esm.js?c894:430)
at HTMLElement.connectedCallback (vue-custom-element.esm.js?c894:57)
at registerCustomElement (vue-custom-element.esm.js?c894:99)
at Function.vueCustomElement [as customElement] (vue-custom-element.esm.js?c894:423)
at eval (index.ts?ffb4:7)
at Object.<anonymous> (build.js:1)
at g (build.js:1)
at build.js:1
at build.js:1
I tried to strip away everything unimportant but am stuck at this point. Any ideas what might went wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Typescript class properties not being initialized - Stack Overflow
The problem is the order of execution. Field initializers are just syntactic sugar for fields assigned in the constructor, but the first ...
Read more >Class Components - React TypeScript Cheatsheets
Within TypeScript, React.Component is a generic type (aka React.Component), so you want to provide it with (optional) prop and state type parameters:
Read more >How to create React components with TypeScript
We'll typically use constructors to initialize our class component's state. Unfortunately, the React class won't know the type of our props ...
Read more >How to properly define state in React components - ITNEXT
If you have been using React, there is a 100% chance that you know the pattern of initializing a component's state in it's...
Read more >TypeScript and React: Components - fettblog.eu
Components are at the heart of React. Let's see what we can do to get better error handling and tooling for them! In...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sonovice Hi, you are right. It’s because
vue-class-component
returns constructor. I checked and to make it works you have to use:Hope it will work now. Regards!
… my bad. Thank you so much! It works now.