I'm trying to use Fontawesome's React module of Free solid icons in a React based Design System. I want to access Fontawesome Icon as a string that is rendered by the FontAwesomeIcon component
Eg:
<FontAwesomeIcon icon="coffee"/>
or
<FontAwesomeIcon icon={['fas', iconProp]}
If this happens inside a React component, say Button
component, which is a named export, should I import the Library (import './fontAwesomeLibrary.js'
) of icons in every other component in the Design system?
The library file:
// fontAwesomeLibrary.js
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
library.add(fas)