feathericons / react-feather

React component for Feather icons

Home Page:https://npm.im/react-feather

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I set icon dynamically?

fabercs opened this issue · comments

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?

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

#41 (comment)

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