I need to import component based on the name I get from backend. Since I can spread and get the component name from the props only, is it fine to use dynamic import inside the component? Does it have any downsides?
import React from "react";
import Link from "next/link";
import dynamic from "next/dynamic";
const DropdownItem = ({ iconName }) => {
const Icon = dynamic(() => import(`components/icons/${iconName}`));
return (
<Link href="/" passHref>
<Icon />
</Link>
);
};
export default DropdownItem;