-
-
Notifications
You must be signed in to change notification settings - Fork 302
bug: react element key hardcoded to 100 (?!?), index keys used frequently #35
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
Comments
this is less than ideal but it fixes the immediate problem. see the corresponding issue for more information on a more lasting fix: praneshr#35
As an aside @praneshr I am curious why you wrote |
Also.. for balance: Thank you for open sourcing this project. From the search I did for all the competition's offerings I found this to be the best. |
Hi @dimitropoulos, thanks for pointing this out. This is a serious bug. I meant to write |
Fixed in v2.0.3 |
I think @praneshr something happened with the npm release: |
Uh oh!
There was an error while loading. Please reload this page.
Observe the following snippet of code from index.tsx:
Now consider the following sandbox example: https://codesandbox.io/embed/proud-firefly-wlko9
This is a serious bug.
This example demonstrates that when there's a row that has a key that's based off of the index two react elements will exist with the same key, which, of course, causes react to go crazy. In my specific app, which datafetches the thing that's being diffed, it results in the row being duplicated every few seconds (such that if you have the app open for 60 seconds, you might have 60 duplicated rows).
React depends on keys being unique among siblings.
Furthermore, it's widely considered an antipattern to use array indexes as keys [sources: 1, 2, 3, 4], something that's done very frequently in this project [source 1, 2, 3, 4, 5, 6].
I understand that this is a tough cookie to crack because with a library like this you don't have very many guarantees. You can't exactly force the end user to provide an id for every row/column/whatever. To solve this problem in the past for similar problems I've used some of the solutions suggested in the linked resources on this antipattern above (e.g. shortid).
This bug was introduced here.
The text was updated successfully, but these errors were encountered: