wmira / react-icons-kit

React Svg Icons
https://react-icons-kit.vercel.app/
MIT License
370 stars 45 forks source link

Dynamic Icons #40

Closed juhamm closed 4 years ago

juhamm commented 5 years ago

How to get Icons dynamically? `.... import { Icon } from 'react-icons-kit' import {facebook} from 'react-icons-kit/feather/facebook'; import {instagram} from 'react-icons-kit/feather/instagram'; import {twitter} from 'react-icons-kit/feather/twitter'; ....

// dynamic array from redux store "sociallinks": [ { "_id": 1, "type": "facebook", "linkname": "Facebook", "link": "https://www.facebook.com/zzzzz/" }, { "_id": 2, "type": "instagram", "linkname": "Instagram", "link": "https://www.instagram.com/yyy/" }, { "_id": 3, "type": "twitter", "linkname": "Twitter", "link": "https://twitter.com/xxx" }, { "_id": 4, "type": "youtube", "linkname": "Youtube", "link": "https://www.youtube.com/user/youtube" } ]

// problem is here how to markup icon = {xxxxx} from map item.type? item.lin and item.linkname woks fine..

` .....
wmira commented 4 years ago

@juhamm you can import all the icons e.g. import featherIcos from 'react-icons-kit/feather Object.keys(featherIcos) should give you the list, but do note you are going to be including this in your package