【问题标题】:How Can I Render react-icons我如何渲染反应图标
【发布时间】:2021-08-24 03:23:13
【问题描述】:

如何渲染 react-icons 我如何渲染 react-icons 我如何渲染 react-icons 我如何渲染 react-icons

【问题讨论】:

    标签: javascript reactjs typescript tailwind-css strapi


    【解决方案1】:

    您应该能够使用find 方法,然后将找到的项目的icon 添加到您的JSX:

    const icons = [
      { name: 'react', icon: <FaReact /> },
      { name: 'tailwind', icon: <SiTailwindcss /> },
    ];
    
    
    function MyComponent() {
      const found = icons.find(({ name }) => name === 'react');
    
      return <>{found.icon}</>;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      相关资源
      最近更新 更多