You can take Font Awesome with React to the next level by learning a little more about the behind-the-scenes stuff that we do to load icons and fine-tuning it to exactly what you need.
Advertisement
Remove ads with a Pro plan!
A subscription to a Pro-level plan will remove all third-party advertisements on fontawesome.com.
And of course Pro-level plans come with…
All 26,233 icons in Font Awesome
5 Classic styles of every icon
3 Sharp styles of every icon
A Perpetual License to use Pro
Services and tools to make easy work of using icons
When testing components, you’ll want to make sure that any icons referenced in those components are available for testing purposes. You have a couple choices here:
If you want to test a child component on its own, you can import its icons explicitly.
If you’ve built a library instead, and your test doesn’t include your root component that defines your library of icons, you may see errors like this:
Could not find icon {prefix:'fas',iconName:'chevron-right'}
If this happens, and the icon isn’t important to the particular test, you can mock FontAwesomeIcon like this:
With create-react-app, you can put this code in src/__mocks__/@fortawesome/react-fontawesome.js to automatically include it in any tests, and alleviate errors.