This will give an error but hopefully it shows pretty much but I want to do. I want to have a bunch of icons in my component (later on they will be links) but I'm wondering if there's a way to bring them in dynamically rather than hard-coding them.
Data
const icons = [
{
title: 'BsGithub',
path: 'bs'
}, {
title: 'BsStackOverflow',
path: 'bs'
}, {
title: 'BsLinkedin',
path: 'bs'
},
]
export default icons
Component File
import icons from '../../data/icons'
const MyComponent = () => {
const getIcon = ({ title, path }) => {
import { title } from `react-icons/${path}`
return(
<h1>
<{title} />
</h1>
)
}
return(
<div>
{icons.map(icon => getIcon(icon))}
</div>
)
}