Help: using fontawesome with React in codepen?

Hi, for some reason I don’t seem to be able to get the font-awesome twitter icon to render.

Here is the link to the pen:

I’ve been googling all day and have tried importing several libraries (I think?) and nothing seems to work! The “residue” of this process is still left in the pen. I’m not sure if React was the best choice for this project, but I was really keen to try it out!

Hopefully someone out there can help me out here! I’d really like to understand what’s going on here, not just how to make it work but why it isn’t working.

Thanks very much in advance :slight_smile:

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Build a Random Quote Machine

Link to the challenge:

I would suggest you use CodeSandbox instead.

I find the Font Awesome React docs a bit confusing.

This seems to work for me on Codepen:


import { FontAwesomeIcon } from ""
import { faTwitter } from "";

Component usage:

<FontAwesomeIcon icon={faTwitter}/>

If you want to use the {['fab', 'twitter']} syntax I think you have to use the loader.


import { FontAwesomeIcon } from ""
import { fab } from "";
import { library } from "";


Component usage:

<FontAwesomeIcon icon={['fab', 'twitter']}/>

Edit: Here is a CodeSandbox as well with your code and your dependencies, just in case. You can fork it by creating an account and saving it.

Thanks so much, this is incredibly helpful!

The docs have done nothing but confuse me all day :sweat_smile:

I tried putting my code into CodeSandbox but couldn’t quite get the styling the same and still couldn’t get the fontawesome icon - so this will be really useful to compare and see what I’ve missed/where I went wrong.

Thanks again so much for your help!

Glad to have helped, happy coding!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.