Mitosis angular output accessing nativeElement when undefined
See original GitHub issueI am interested in helping provide a fix!
Yes
Which generators are impacted?
- All
- Angular
- HTML
- Qwik
- React
- React-Native
- Solid
- Stencil
- Svelte
- Vue
- Web components
Reproduction case
Expected Behaviour
Angular output
if (!this.someRef?.nativeElement) {
return;
}
Actual Behaviour
Angular output
if (!this.someRef.nativeElement) {
return;
}
Additional Information
Shows errors in the console “ERROR TypeError: Cannot read properties of undefined (reading ‘nativeElement’)” see stackblitz
Also causes other issues where classes inside “classNames” function do not appear in the dom when they should.
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Angular: nativeElement is undefined on ViewChild
But when I try to access the nativeElement property, it's undefined . Below is the snippet. import { Component, ViewChild, AfterViewInit } from ......
Read more >When using @ViewChild element.nativeElement is undefined
This is working as expected. When using @ViewChild in this way, Angular will provide the directive instance.
Read more >Cannot read property 'nativeElement' of undefined and ...
It seems clear to me that Angular is failing to grab the #cardElement but I can't see what's wrong in the code. subscriptions.component.html...
Read more >ILSI - Springer Link
The present volume is one of a series concerned with topics considered to be of growing interest to those whose ultimate aim is....
Read more >3458.txt - Project Gutenberg
YOU USE OR READ THIS ETEXT By using or reading any part of this PROJECT ... The per- 68:24 petuation of the floral...
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
Closing this ticket since with Patrick’s solution the
nativeElement
is no longerundefined
.yeah you do
const fn = useRef((evt) => handleClickOutside(evt));
so the mitosis angular output would need to be updated later