How to include a Font Awesome icon in React's render()

前端 未结 15 1624
刺人心
刺人心 2020-12-04 06:30

Whenever I try to use a Font Awesome icon in React\'s render(), it isn\'t displayed on the resulting web page although it works in normal HTML.

         


        
15条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 06:44

    as 'Praveen M P' said you can install font-awesome as a package. if you have yarn you can run:

     yarn add font-awesome
    

    If you don't have yarn do as Praveen said and do:

    npm install --save font-awesome
    

    this will add the package to your projects dependencies and install the package in your node_modules folder. in your App.js file add

    import 'font-awesome/css/font-awesome.min.css'
    

提交回复
热议问题