FortAwesome / react-fontawesome

Font Awesome React component
https://fontawesome.com
MIT License
3.67k stars 264 forks source link

"icon" props is not working as the documentation described #510

Closed namti closed 2 years ago

namti commented 2 years ago

Describe the bug <FontAwesomeIcon /> icon is not working as the documentation describes.

image

Reproducible test case Source code

Expected behavior These icon props should work.

<FontAwesomeIcon icon="coffee" />
<FontAwesomeIcon icon={['fas', 'coffee']} />
<FontAwesomeIcon icon={faCoffee} />

Desktop (please complete the following information):

tickoosunny commented 2 years ago

Yes, even not working for me :(

Minho-Lee commented 2 years ago

According to the docs, if you want to use icon="coffee" or icon={['fas', 'coffee']} format, you have to add icons globally first.

So in your code snippet, if you add,

import { fas, faCoffee } from "@fortawesome/free-solid-svg-icons";
import { library } from '@fortawesome/fontawesome-svg-core';

and

componentDidMount() {
    library.add(fas, faCoffee);
  }

You will see Screen Shot 2022-05-26 at 10 22 10 AM

For more info, here

namti commented 2 years ago

Thanks @Minho-Lee