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

UI: Fix React unique key warning when using renderLabel #14172

Merged
merged 1 commit into from Mar 9, 2021

Conversation

ghengeveld
Copy link
Member

Issue: #14102

What I did

Somehow React thinks the result of invoking renderLabel is an array and logs a 'key prop' warning. I suspect this happened because we were calling the renderLabel function outside of a React tree context, passing the result along in the story data before injecting it elsewhere in a React tree. Needless to say the only way I was able to fix it without affecting the user-facing API was by passing the function itself along in the story data and invoking it where we're rendering it. It might actually be more memory efficient because we're passing the same function reference for each story.

How to test

  • Is this testable with Jest or Chromatic screenshots? No
  • Does this need a new example in the kitchen sink apps? No
  • Does this need an update to the documentation? No

If your answer is yes to any of these, please make sure to include it in your PR.

@ghengeveld ghengeveld added the maintenance User-facing maintenance tasks label Mar 8, 2021
@ghengeveld ghengeveld requested a review from shilman March 8, 2021 20:15
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

💯

@shilman shilman added bug ui and removed maintenance User-facing maintenance tasks labels Mar 9, 2021
@shilman shilman changed the title Fix React unique key warning when using renderLabel UI: Fix React unique key warning when using renderLabel Mar 9, 2021
@shilman
Copy link
Member

shilman commented Mar 9, 2021

@shilman shilman merged commit 05078ff into next Mar 9, 2021
@shilman shilman deleted the fix-renderLabel-key-warning branch March 9, 2021 23:07
This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants