Add icon name prop
See original GitHub issueDoes it not make sense to have a reusable icon component of our own that utilizes react-feather, and therefore be able to do something like <Icon icon={this.props.icon} />
?
I’m aware that we can always pass an icon like <Camera />
down as a prop, but I’m wondering if it’s possible to this just by the name of the icon.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:19
Top Results From Across the Web
reactjs - How to pass an icon as a prop? - Stack Overflow
I'm using props and I want to have "optionText" and "optionIcon" the 1st one I'm able to add but I'm not able to...
Read more >Passing icons as props in a consistent way using React
The first thing we see are IconTypeProps which are the props your generic icons should take in. If we're referring to the initial...
Read more >Add Icons with React | Font Awesome Docs
There are a few ways of adding icons to a React project. Choose the option that works for your project, and then add...
Read more >Icon - React Native Elements
Custom Icon Fonts ... Register your own custom icons by calling registerCustomIconType('customid', customFont) . Create a custom font by following the ...
Read more >Icons · React Native Paper - Open Source
You can pass the name of an icon from MaterialCommunityIcons . This will use the react-native-vector-icons library to display the icon. Example: < ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone interested, I just wrote this functional component which will render an icon by name (in TypeScript):
You could always abstract this kind of behavour, but otherwise doing the following would allow you a similar experience (Almost).