Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add link to Font Awesome icon in ReactJS

I use Typescript + ReactJS and I try to add a link in font awesome icons. My code is like this:

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


const MiddleHeading = () => {
     return (
         <div id="middle_heading">  

              <FontAwesomeIcon icon={faRandom} size="2x"/>          

         </div>
     );
 };

 export default MiddleHeading;

Any idea on how to add a URL to my icon?

thanks for any help

like image 999
user3417479 Avatar asked Dec 05 '22 09:12

user3417479


1 Answers

You do not need Link from react-router-dom at all as mentioned in the other answer. Just a simple HTML <a> will work

<div id="middle_heading">  
  <a href="example.com">
    <FontAwesomeIcon icon={faRandom} size="2x"/>      
  </a>    
</div>
like image 118
rsn Avatar answered Dec 08 '22 00:12

rsn