0

We need to import different icon packs from react-icons by different import line. e.g: import {FaUser} from 'react-icons/fa But in my case I'm taking the icon names from json file and trying to destucture and show them in my component. Icons can be from multiple packs.So, I need to import the whole pack. Is there any solution for this?

{
    title: 'Home',
    url: '/',
    icon: 'ImHome',
  },
  {
    title: 'About',
    url: '/about',
    icon: 'FaUserCircle',
  },

import * as Icons from 'react-icons/all';

const CustomIcons = ({ icon, className }) => {
  const { [icon]: Icon } = Icons;
  return (

    <div className={className}>
      <Icon />
    </div>
  );
};

export default CustomIcons;


0 Answers0