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.

[FontIcon] Backward incompatible with Font Awesome v5 ?

See original GitHub issue

Hey,

Here is what I observed : The HTML class names on a FontIcon correctly update on prop change when using Material Icons, but not when using Font Awesome.

For instance, this updates when connectionLost changes :

const active = connectionLost ? 'active' : ''
// ...
<FontIcon
  className={ `logo-offline-icon ${ active }` }/>
    power_settings_new
</FontIcon>

This doesn’t :

const active = connectionLost ? 'active' : ''
// ...
<FontIcon
  className={ `logo-offline-icon ${ active }` }
  iconClassName='fab fa-stumbleupon'
/>

I use the last version of Font Awesome (v5) and things have slightly changed. They now use <svg>. Can it be that ?

I saw that you render an <i> tag anyway, but it is an <svg> that is actually rendered on the DOM.

<svg class="svg-inline--fa fa-stumbleupon fa-w-16 md-icon logo-offline-icon active" aria-hidden="true" data-prefix="fab" data-icon="stumbleupon" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg="">
  <path fill="currentColor" d="M502.9 266v69.7c0 62.1-50.3 112.4-112.4 112.4-61.8 0-112.4-49.8-112.4-111.3v-70.2l34.3 16 51.1-15.2V338c0 14.7 12 26.5 26.7 26.5S417 352.7 417 338v-72h85.9zm-224.7-58.2l34.3 16 51.1-15.2V173c0-60.5-51.1-109-112.1-109-60.8 0-112.1 48.2-112.1 108.2v162.4c0 14.9-12 26.7-26.7 26.7S86 349.5 86 334.6V266H0v69.7C0 397.7 50.3 448 112.4 448c61.6 0 112.4-49.5 112.4-110.8V176.9c0-14.7 12-26.7 26.7-26.7s26.7 12 26.7 26.7v30.9z"></path>
</svg>

Probably some magic in there :

<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

My bug may just be a little symptom of a bigger backward compatibility issue, my guess. It seems like the Font Awesome script overwrites the <i> tag, and then React loses all control over it.

Workaround for the className issue : Using a wrapper, and then styling with the appropriate selector :

.wrapper.active > .md-icon {
  ...
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Jared-Devcommented, Aug 14, 2018

@mlaursen I’m guessing this one can be closed.

1reaction
strblrcommented, Aug 11, 2018

Yep, I missed that part. It might do the job, I’ll give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's Changed | Font Awesome Docs
We've tried our hardest to make Version 6 backward compatible with Font ... Added Aliases for v4/v5 Icon Names, Any icons that had...
Read more >
backward Icon | Font Awesome
This is a Pro icon!​​ To use the solid style of “backward“, you'll need a subscription to a Pro-level plan or a perpetual...
Read more >
Upgrade From Version 4 | Font Awesome Docs
Old Icon Name or Alias (Version 4) New Icon Name (Version 5) New Icon Prefix Unicode v... 500px 500px fab f26e address‑book‑o address‑book far f2b9 address‑card‑o...
Read more >
Upgrade to Version 6 | Font Awesome Docs
Backward Compatible by Default! If your project uses Version 5 icons, style names, or custom CSS rules with Font Awesome @font-face rules, your...
Read more >
Layer, Text, & Counters | Font Awesome Docs
Familiar with the basics of adding Font Awesome icons. Layers are awesome when you don't want your page's background to show through, or...
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