-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Just warn on clashing keys but proceed with render #566
Comments
Because keys are optional, it should indeed just warn in prod, not break. But perhaps uniqueness is relied on in too many places to handle a special case of invalid keys nicely? |
The fact that keys are optional has nothing to do with this. React should have the same behavior in dev and prod but it's perfectly reasonable to throw (as now) or warn. |
@spicyj Sorry I meant that as an api user one could assume that keys are just to help react in reusing component instances and if one supplies invalid keys then one could assume that then they are just no help and slower way proceeds. So I support your cause :) |
We've hit a couple bugs in prod now where keys are supposed to be distinct but aren't, which causes React to throw errors and render nothing.
It would be nice if React could instead warn and render all the components anyway (perhaps adding some suffix to make the keys unique) or render only one of the components with the same ID. Both of these seem preferable to completely dying (though maybe this is just our fault for not properly having our JS error reporting figured out…).
The text was updated successfully, but these errors were encountered: