Skip to content

Instantly share code, notes, and snippets.

View debotos's full-sized avatar
🏃‍♂️
I may be slow to respond.

Debotos Das debotos

🏃‍♂️
I may be slow to respond.
View GitHub Profile
@debotos
debotos / load-dynamically-icon-from-react-icons-lib.js
Created September 8, 2020 11:52
Load any icon dynamically from 'react-icons' lib.
import React from 'react'
import loadable from '@loadable/component'
const getDynamicIcon = (iconName = 'fa/FaFileExcel') => {
const [library, iconComponent] = iconName.split('/')
// console.log({ library, iconComponent })
if (!library || !iconComponent) return
const lib = library.toLowerCase()
let ReactIcons = loadable.lib(() => import(`react-icons/ai`))