Love me some Font Awesome. Absolutely wonderful. However, I came a cropper when following the instructions on using the all new Font Awesome 5 with React. The instructions for standard icons work fine. But if you want to use brand icons then this does not help you out much. There's 2 problems:
- Font Awesome's brand icons are not part of
- The method of icon usage illustrated (i.e. with the
FontAwesomeIconcomponent) doesn't work. It doesn't render owt.
You want brands? Well you need the
<a href="https://www.npmjs.com/package/@fortawesome/free-brands-svg-icons">@fortawesome/free-brands-svg-icons</a>. Obvs, right?
Here we've ditched the "library / magic-string" approach from the documentation for one which explicitly imports and uses the required icons. I suspect this will be good for tree-shaking as well but, hand-on-heart, I haven't rigorously tested that. I'm not sure why the approach I'm using isn't documented actually. Mysterious! I've seen no ill-effects from using it but perhaps YMMV. Proceed with caution...
Yup - information on this approach is out there; but it's less obvious than you might hope. Read all about it here. For what it's worth, the explicit import approach seems to be playing second fiddle to the library / magic-string one. I'm not too sure why. For my money, explicit imports are clearer, less prone to errors and better setup for optimisation. Go figure...
Feel free to set me straight in the comments!