-
-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed the exemple of dynamic icons using NextJS #1580
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from me.
IMO we should remove the dynamicIconImports
file, it's an antipattern and only leads to performance bottlenecks and flickering.
And hey, you can do this other ways such as described by your change here.
@KajSzy converting the name to pascal case solved my issue. Dev server is super fast now. Thanks! |
@morrisseybr this only works client-side. Any idea how to make it work within a Server Component? |
|
||
export default Icon | ||
export default Icon; | ||
``` | ||
|
||
##### NextJS Example | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make separate sections for the App router and pages router.
Pages router should use the docs like it was before.
And create a new section specially targeting the App Router.
With this code example:
import { LucideProps, icons } from 'lucide-react';
interface IconProps extends LucideProps {
name: keyof typeof icons;
}
const Icon = ({ name, ...props }: IconProps) => {
const LucideIcon = icons[name];
return <LucideIcon {...props} />;
};
export default Icon;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, so is this the solution for dynamic import with the app router?
This pr resolves the issue #1576.