Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
An icon of fontawesome doesn't apeear in react code

I try to assimilate an icon of fontawesome in react and the icon not apeear and I get an error in the console.

Here's the code:

import PropTypes from "prop-types";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const SearchBar = ({ handleChange }) => {
  return (
    <div className="field">
      <FontAwesomeIcon icon="fa-regular fa-magnifying-glass" />
      <input
        type="search"
        className="text-rtl form-control"
        placeholder="חפש מוצר"
        onInput={handleChange}
      />
    </div>
 
  );
};

SearchBar.propTypes = {
  handleChange: PropTypes.func.isRequired,
};

export default SearchBar;

And in the file of the index.html I worte the js code:

  <script
      src="https://kit.fontawesome.com/ab8447aa04.js"
      crossorigin="anonymous"
    ></script>

And I connected to the site of fontawesome. So Why there is a problem?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You no need for react-fontawesome package, you have a Fontawesome CDN in index.html

<script
    src="https://kit.fontawesome.com/ab8447aa04.js"
    crossorigin="anonymous"
></script>

just add <i className="fa-regular fa-magnifying-glass"></i>

about 4 years ago · Juan Pablo Isaza Report

0

I think your configuration is mixed up between react & non react usage. For react, you don't need to include the script in index.html.

For react there are three dependencies -

npm i --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons
npm install --save @fortawesome/react-fontawesome

After that it is as simple as -

// import icon component
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
// import the icon
import { faCoffee } from "@fortawesome/free-solid-svg-icons";
// usage
<FontAwesomeIcon icon={faCoffee} />

Edit confident-fire-wmp7br

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!