question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'html' of undefined

See original GitHub issue

I’m getting the follow error:

ERROR TypeError: Cannot read property 'html' of undefined
at FaIconComponent.ngOnChanges (angular-fontawesome.es5.js:106)

// @TODO: make sure that it doesn't break things to do html[0] here.
this.renderedIconHTML = this.sanitizer.bypassSecurityTrustHtml(renderedIcon.html[0]);

app.module

import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

imports: [
    ...
    FontAwesomeModule
  ],

component.html

<fa-icon [icon]="faUser"></fa-icon>

package.json

"@angular": "^5.2.0",
"@fortawesome/angular-fontawesome": "0.1.0-3",
"@fortawesome/fontawesome": "^1.1.3",
"@fortawesome/fontawesome-free-solid": "^5.0.6",

What could I be missing?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mlwilkersoncommented, Feb 21, 2018

I’m working on adding something to the example in the repo that will clarify how to reference icons with non-default prefixes.

As for your workaround, while that may work, it is essentially avoiding the Angular component and instead relying on our autoReplaceSvg functionality to translate <i> tags into <svg>. If you’re satisfied with that, great. But you may find it more performant (including having smaller bundle size) to import only those icons that you intend to use and add them to the library, or make them available as objects to your templates.

I’d like to leave this issue open for the moment, because I do want to fix the error handling problem you stumbled onto here.

1reaction
robmadolecommented, Feb 22, 2018

@mlwilkerson you da man 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'html' of undefined after jest update
In my package.json there is no jest-environment-jsdom . But I noticed that I have many outdated packages. If updating them fixes it, I'll...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong...
Read more >
[Solved] Cannot read Properties of Undefined in JavaScript
The "Cannot read properties of undefined" error occurs when you try to access a property or a method on a variable that stores...
Read more >
Cannot read property 'html' of undefined · Issue #114 - GitHub
I am having the same problem with ngx-summernote v0.7.4 . I found a solution by adding this line in node_modules/ngx-summernote/fesm5/ngx- ...
Read more >
Cannot read property 'html' of undefined after jest update ...
I had this same issue and noticed that jest-environment-jsdom was on version 27. I installed v28 to match the jest version and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found