-1

I'm trying to use FontAwesome with React.js but it is not working.

In Button.js I have:

import React from "react";
import FontAwesome from "react-fontawesome";
const Button = () => {
   return <FontAwesome name="rocket" />;
};
export default Button;

and in index.html I included the FontAwesome CDN: https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css

Any suggestions?

stochazesthai
  • 617
  • 1
  • 7
  • 20
  • Check this may be it will solve you issue: https://stackoverflow.com/questions/23116591/how-to-include-a-font-awesome-icon-in-reacts-render – Mayank Shukla Jul 28 '17 at 07:33

1 Answers1

0

There's not a problem with react-fontawesome package, but the problem is in your react code, you are write return FontAwesome component outside of function, your react apps will not work.

Look this Button component with font-awesome, don't forget for import React in Button.js, and ofcourse import font-awesome css in your index.html.

import React from "react";
import FontAwesome from "react-fontawesome";
const Button = () => {
    return <FontAwesome name="rocket" />;
};
export default Button;

Then you just need to import Button from Button.js

...
import Button from "./Button";

...
<Button />
...
Rahmat Aligos
  • 1,164
  • 11
  • 13