Open HOJOON07 opened 7 months ago
In the sidebar and navigation bar components, I was importing each icon component and using icons via the name attribute. However, every time an icon was clicked or an event occurred, all the icon components exhibited a flickering issue.
I was able to resolve it by adding React.memo.
import dynamic from 'next/dynamic'; import { memo } from 'react'; import { LucideProps } from 'lucide-react'; import dynamicIconImports from 'lucide-react/dynamicIconImports'; interface IconProps extends LucideProps { name: keyof typeof dynamicIconImports; } const Icon = memo(({ name, ...props }: IconProps) => { const LucideIcon = dynamic(dynamicIconImports[name]); return <LucideIcon {...props} />; }); export default Icon;
Same issue here, also this causing hot reload in client component very laggy.
Package
Description
In the sidebar and navigation bar components, I was importing each icon component and using icons via the name attribute. However, every time an icon was clicked or an event occurred, all the icon components exhibited a flickering issue.
Use cases
I was able to resolve it by adding React.memo.
Checklist