I dynamically create an element based on passed ID:
const Icon: FC<IconPropsI> = ({iconId, ...rest}) => {
const iconsMap: IconsMapT = {
IconUser: IconUser,
IconTime: IconTime,
IconVideo: IconVideo
}
return createElement(iconsMap[iconId], rest)
}
Value of each map property has corresponding functional component.
I would like to avoid repeating myself. I have created a list of IDs instead. With the following array...
export const IconsIds: IconsIdsT = [ 'IconUser', 'IconTime', 'IconVideo', 'manymore...']
...how can I create the map dynamically inside the Icon
component, so I don't have to write 200+ different icon IDs three times?