icons-pack / react-simple-icons

📦 This package provides the Simple Icons packaged as a set of React components.
MIT License
287 stars 18 forks source link

Is there a way to get icon component by specific enum name? #207

Closed jsonchou closed 5 months ago

jsonchou commented 8 months ago

Hi, Is there a way to get icon component by specific enum name?

 <Fragment>
    {getSpecificIcon("react")}
  </Fragment>

or 

 <Fragment>
    <SpecificIcon name="react" {...props} />
  </Fragment>
wootsbot commented 8 months ago

@jsonchou At the moment, there is nothing similar, which I think would be a good feature for a future version. This is very common, especially when you want to create conditions that render a specific icon.

SebastienPingal commented 6 months ago

I'm looking at it, but the major problem is that the SVG is not separated from the React component, making it difficult to extract in order to use it in another component.

It looks like it needs an architectural rework :

Seem the right way to do it, but I may be wrong. Plus, I think that importing SVGs like that may a bit tricky or require other library like react-svg-loader

LitoMore commented 5 months ago

This will need to pack all icons into your build. It's not a good practice.

<SpecificIcon name="react" {...props} />

You can use CDN links instead as a workaround.

Or use the https://npmjs.com/simple-icons directly.

jsonchou commented 5 months ago

Yes, this will lose the function of Tree Shaking. I request to close this issue. @wootsbot