feathericons / react-feather

React component for Feather icons
https://npm.im/react-feather
MIT License
1.93k stars 126 forks source link

How can I set icon dynamically? #82

Closed fabercs closed 3 years ago

fabercs commented 3 years ago

In my app, icon names come from an external resource as strings for the navigation.

{
   "nav":[
      {
         "id":1,
         "title":"Home",
         "icon":"Home"
      }
   ]
}

I need something like;

<Icon name={item.icon} />

I couldn't find a way to create this icon dynamically, can't we do this?

aelfric commented 3 years ago

I haven't used it myself, but is this what you're looking for?

https://github.com/feathericons/react-feather/issues/41#issuecomment-657059256

fabercs commented 3 years ago

@aelfric This is exactly what I was looking for, thank you!