Currently I am using the following code to import some module dynamically using web-packe.
I would like to know if there is a way to avoid the switch. Thanks
import React from 'react'
import iconSend from './icon-send.png'
import iconReload from './icon-reload.png'
import iconDownload from './icon-download.png'
import iconAddDoc from './icon-add-doc.png'
import iconAddAgendaItem from './icon-add-agenda-item.png'
const loadIcon = (src) => {
switch (src) {
case 'iconSend':
return iconSend
case 'iconReload':
return iconReload
case 'iconDownload':
return iconDownload
case 'iconAddDoc':
return iconAddDoc
case 'iconAddAgendaItem':
return iconAddAgendaItem
}
}
const Option = ({id, name, isActive, src}) => {
return (
<div>
<div>
<img src={loadIcon(src)} alt={name} />
</div>
</div>
)
}
export default Option