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

Duplicate keys on passing array of ReactElement #18

Closed
pbshgthm opened this issue Aug 24, 2021 · 3 comments
Closed

Duplicate keys on passing array of ReactElement #18

pbshgthm opened this issue Aug 24, 2021 · 3 comments

Comments

@pbshgthm
Copy link

I have defined a custom component that adds emoji

export function RenderEmoji({ content }: { content: any }) {
  return emoji(content, (code, string, key) => (
    <img srrc={`https://twemoji.maxcdn.com/2/svg/${code}.svg`} alt={string} key={key} />
  ))
}

When content is a ReactElement array, it sometimes throws the following warning
Encountered two children with the same key. This happens as the key is offset from the start of that particular element so when content is ["🧡 abc", "🧡 xyz"] both the returned images have the same key 0.

How to handle this situation?

@oztune
Copy link
Member

oztune commented Aug 24, 2021

Great catch! We'll look into this.

oztune added a commit that referenced this issue Aug 24, 2021
@oztune
Copy link
Member

oztune commented Aug 24, 2021

This is now fixed in v1.6.1. Thanks for letting us know!

@oztune oztune closed this as completed Aug 24, 2021
@pbshgthm
Copy link
Author

Thanks for the super fast fix!

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

No branches or pull requests

2 participants