Skip to content
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

fix: add unique keys to iconNode and children to resolve React errors #2655

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hypervisor
Copy link

What is the purpose of this pull request?

  • New Icon
  • Bug fix
  • New Feature
  • Documentation update
  • Other:

Description

This PR resolves the missing key warnings in the Icon component by adding unique key props to the elements created from iconNode and children.

Closes #2654

Before Submitting

packages/lucide-react/src/Icon.ts Outdated Show resolved Hide resolved
@hypervisor
Copy link
Author

@ericfennis Good catch, I applied your suggested changes

Copy link
Member

@jguddas jguddas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's a good idea, using indexes as keys is not something we should do.

@ericfennis
Copy link
Member

@jguddas This is only when custom icons are added. The icon nodes we provide have random keys generated based on the content.

@jguddas
Copy link
Member

jguddas commented Dec 20, 2024

My opinion stays the same, we should not do this. If you want to fix the error add keys to your custom icon data, https://lucide-studio.vercel.app does it automatically already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

createLucideIcon causes missing key error in React
3 participants