Search code examples
reactjsfont-awesome

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


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.

render: function() {
    return <div><i class="fa fa-spinner fa-spin">no spinner but why</i></div>;
}

Here is an live example: http://jsfiddle.net/pLWS3/

Where is the fault?


Solution

  • React uses the className attribute, like the DOM.

    If you use the development build, and look at the console, there's a warning. You can see this on the jsfiddle.

    Warning: Unknown DOM property class. Did you mean className?