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

前端 未结 15 1630
刺人心
刺人心 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:46

    If you are new to React JS and using create-react-app cli command to create the application, then run the following NPM command to include the latest version of font-awesome.

    npm install --save font-awesome
    

    import font-awesome to your index.js file. Just add below line to your index.js file

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

    or

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

    Don't forget to use className as attribute

     render: function() {
        return 
    no spinner but why
    ; }

提交回复
热议问题