Desktop display issue: Fontawesome icon not appearing

Having trouble getting the fontawesome icon to display properly on my website. It appears in inspect mode, but not on the actual site itself.

Any suggestions on how to fix this issue?

import React, { Fragment, useState} from "react";
import { NavLink } from "react-router-dom";
import "../styles/common/Navbar.css";


const Navbar = () => {
    const [showMenu, setShowMenu] = useState(false);

    return (
      <Fragment>
          <nav>
              <a href="/">
              <h1>AnRa<span>Caribbean</span></h1>
              </a>
              <div className={showMenu ? "menu mobile-menu" : "menu"}>
                  <ul>
                      <li><NavLink to="/">Home</NavLink></li>
                      <li><NavLink to="/PropertiesForSale">Buy a Property</NavLink></li>
                      <li><NavLink to="/PropertiesForRent">Rent a Property</NavLink></li>
                      <li><NavLink to="/About">About</NavLink></li>
                      <li><NavLink to="/Contact">Contact</NavLink></li>
                  </ul>
                  <button className="btn">
                      <NavLink to="#">Add Property</NavLink>
                  </button>
              </div>
              <i className="fa fa-solid fa-bars" onClick={() => setShowMenu(!showMenu)}></i>

          </nav>
      </Fragment>
    );
}

export default Navbar;

View Image Here

CSS for max-width screen:

.fa-bars{
    display: flex;
    color: gold;
}

Appreciate any help or advice.

  1. Tried installing dependencies again
npm i --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons

Still unable to resolve the issue.

  1. Attempted deleting nodemodules directory.
  2. Restarted the application.

No luck so far.

Answer №1

According to the documentation provided by Font Awesome, the recommended way to use their icons is as follows:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCoffee } from '@fortawesome/free-solid-svg-icons'

const MyApp = () => {
   return (<div><FontAwesomeIcon icon={faCoffee} /></div>)
}

export default MyApp

Answer №2

Were all the steps in the guide followed correctly? Step number three involves adding the FontAwesomeIcon component and using it like this:

<FontAwesomeIcon icon={faBars} />

Refer to the documentation for more information on how to work with icons.

PS: Remember to import both the component and the specific icon:

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBars } from '@fortawesome/free-solid-svg-icons';

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CRITICAL ERROR: NewSpace::Rebalance Allocation unsuccessful - Insufficient memory in JavaScript heap

When attempting to create a new React app, I encountered the following error message: <--- JS stacktrace ---> FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory 1: 00007FF6C5A67A1F 2: 00007FF6C59F6096 3: 00007FF6C5 ...

Exploring necessary components for react-toggle feature

I am currently facing a challenge with integrating the react-toggle-component library into my project. After installing the necessary dependencies (react, react-circle, react-dom, and styled-components) using npm, I encountered an error message stating &a ...

TypeScript does not properly validate the types of defaultProps

When working with TypeScript 3.0, I consulted the documentation at https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html The recommendation is to use static defaultProps: Pick<Props, "name"> as an explicit type annotation ...

Flowing Waterways and Transmission Control Protocol

I have a unique piece of code that I recently discovered. After running it, I can connect to it using a Telnet client. const network = require('networking'); //creating the server const server = network.createServer(function (connection) { ...

The event listener for jQuery's document.ready doesn't trigger, rendering all jQuery functions ineffective

After researching similar issues on various forums, I have attempted the following troubleshooting steps: replacing all $ with jQuery ensuring the correct src is used implementing jQuery.noConflict() My goal is to retrieve data from a SQLite3 database w ...

Vue automatically clears the INPUT field when disabling it

Have you ever noticed why Vue resets a text input field when it's set to disabled? This behavior is not observed with plain Javascript and also doesn't affect textarea fields. var app = new Vue({ el: '.container', data: { disab ...

Manually reloading the page causes issues with AngularJS routing functionality

I've been attempting to manually reload the page from my browser, but unfortunately it's not working and is displaying an error message: Cannot GET /rate/4 This is what my route setup looks like in Angular: angular.module('routing&ap ...

New button attribute incorporated in AJAX response automatically

data-original-text is automatically added in ajax success. Here is my code before: <button type="submit" disabled class="btn btn-primary btn-lg btn-block loader" id="idBtn">Verify</button> $(document).on("sub ...

Steps to include all dependencies in an angular application

Managing a large Angular application can be challenging. I currently use npm install to install all packages and manually load them in my index.html file, like this: <script src="node_modules/angular/angular.js"></script> Similarly, I load ot ...

Following the upgrade to version 6.3.3, an error appeared in the pipe() function stating TS2557: Expected 0 or more arguments, but received 1 or more

I need some assistance with rxjs 6.3.3 as I am encountering TS2557: Expected at least 0 arguments, but got 1 or more. let currentPath; const pipeArgs = path .map((subPath: string, index: number) => [ flatMap((href: string) => { con ...

Generate the entity and then transfer the data into an array

I am dealing with multi-level hierarchies that need to be displayed in a select list. Once the user selects values from the table column, they should be able to filter by clicking on the column. var name = ['Akansha', 'Navya']; var age ...

Every time I try to install @mui/icons-material, I keep encountering the same error message

npm ERROR! Unable to access the 'pickAlgorithm' property of null npm ERROR! For more details, check the complete log at: C:\Users\User\AppData\Local\npm-cache_logs\2021-11-02T04_49_26_513Z-debug.log ...

Changing the border of an iframe element using jQuery or Javascript from within the iframe itself

Is it possible to set the border of an iframe to zero from within the iframe itself using JavaScript or jQuery? Any guidance on how this can be achieved would be greatly appreciated. Thank you! ...

Having trouble with this code// Does anyone know how to make the div slide in line with other divs when hovering over it?

After spending countless hours analyzing and trying various solutions, I have come to the realization that I need to seek help with my code. The task at hand is proving to be incredibly frustrating, and I have exhausted all other options before resorting t ...

How to Make a Doughnut Chart Using CSS

For a while now, I've been working on filling in 72% of a circle with a hole cut out of the middle. Throughout this process, I have been consulting different resources - like this method for calculating and this one for other aspects. However, I’ve ...

Loading Google Maps with Ajax

Exploring the world of google maps has been quite entertaining for me, however, I find myself in need of some assistance. The issue at hand involves a small block of HTML/Javascript that can be seamlessly integrated into a standard HTML page or loaded into ...

Tips for calculating the total of an array's values

I am seeking a straightforward explanation on how to achieve the following task. I have an array of objects: const data = [ { "_id": "63613c9d1298c1c70e4be684", "NameFood": "Coca", "c ...

What is the best way to utilize an onClick on a button to update a value that is being utilized in a useEffect hook?

I am looking for a way to dynamically change the content displayed in this section without navigating to another page. I have two sets of data - one displaying all blogs and the other showing only blogs authored by "mario". How can I implement a button cli ...

Troubleshooting Problem with Redux-Form and Material-UI Datepicker Field

I've been encountering an issue every time I attempt to display a Field from Redux-form-material-ui. Below is the code for my form: import React, { Component } from 'react'; import { Field, reduxForm } from 'redux-form'; import { ...

Animating the height with jQuery can result in the background color being overlooked

For those curious about the issue, check out the JSFiddle. There seems to be an anomaly where the background of the <ul> element disappears after the animation on the second click. Oddly enough, even though Firebug shows that the CSS style is being a ...