Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is possible to send a Fontawesome icon from one component to another component?

Basically what I’m trying to do is have a single component that builds several items. Items consist only of a title, a description, and the icon. I send the first two without problems, but I can’t think of how to send the second one, because if I send it like the other two, it doesn’t show up on the screen.

example:

These are the items I want to show:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<IndexComponent title ='Professional Assistance' text = 'We have a specialized pre-sales team and an engineering department for the most complex projects' icon = 'faPeopleGroup'/>
<IndexComponent title ='Training and follow-up' text = 'Training for channels and integrators, about the installation and start-up of our products, accompanying them in the post-sale process.' icon = 'faPeopleGroup'/>
<IndexComponent title ='Credit and Financing' text = 'We offer standard and special financing both for the distribution area, as well as for any type of project.' icon = 'faPeopleGroup'/>
<IndexComponent title ='Distribution Center' text = 'We have a warehouse in which our team is in charge of carrying out the logistics in a timely manner, accompanying the dynamism of the business' icon = 'faPeopleGroup'/>

And so I receive it in the component:

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

const IndexComponent = (props) => {
    const title = props.title;
    const text = props.text;
    const icon = props.icon;


    return(
        <>
            <div className='component'>
                <h4>{title}</h4>
                <p>{text}</p>
                <FontAwesomeIcon icon={icon} color="#003a82"/>
            </div>
        </>
    );
}

The problem is that even if I import the icon or FontAwesome, I can’t display it. Is this possible that I propose? Send an icon from one component to another?

>Solution :

Instead of sending the "faPeopleGroup" string to the child component, you should send the icon faPeopleGroup import itself:

<IndexComponent title ='Professional Assistance' text = 'We have a specialized pre-sales team and an engineering department for the most complex projects' icon={faPeopleGroup}/>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading