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

Unique "key" prop warning when using SubComponent #56

Closed
aaronschwartz opened this issue Feb 3, 2017 · 6 comments
Closed

Unique "key" prop warning when using SubComponent #56

aaronschwartz opened this issue Feb 3, 2017 · 6 comments

Comments

@aaronschwartz
Copy link
Contributor

If I add a table with a SubComponent it gives me a "key" warning:

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `src`. See https://fb.me/react-warning-keys for more information.

This happens even including a very simple SubComponent:

SubComponent={(x) => (<div>hi</div>)}

I believe it is because the Expander Cell fields do not have a "key" attribute even though they are within the allVisibleColumns map.
Expander Cell Code

The pivot columns might have the same issue but I haven't tested it.

Overall I'm really happy with this library.

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented Feb 3, 2017 via email

@aaronschwartz
Copy link
Contributor Author

5.0.1

@tannerlinsley
Copy link
Collaborator

Good catch. Could you pr a fix that adds those keys?

@aaronschwartz
Copy link
Contributor Author

aaronschwartz commented Feb 4, 2017 via email

@janzheng
Copy link
Contributor

janzheng commented Feb 8, 2017

Hey Tanner I just updated to 5.0.2 and I'm getting this for my subcomponents.

line 780 doesn't seem to have key={i2} do you think that's the problem?
{SubComponent && ( <ThComponent className={classnames(

@aaronschwartz
Copy link
Contributor Author

I don't think 5.0.2 has the commits that fix those warnings.

I think your commit (1e4f838) is the one that fixed it for SubComponents but that was merged after the commit marked 5.0.2. The commit after yours (e11fdab) fixes the warning for Pivot Tables.

I don't think like 780 needs a key field because it is not the top level component of an array or iterator.

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

3 participants