Don't quite see using index as key has problems?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 11.8k
- Forks
- 7.9k
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
On page https://reactjs.org/docs/reconciliation.html
it is said that
Here is an example of the issues that can be caused by using indexes as keys on CodePen
How can the issue be created? I added record to the front, to the back, and sort them, and they seemed to work ok?
Actually, here is a simple case and I can't break it: https://stackoverflow.com/questions/60283967/in-reactjs-using-array-index-as-key-is-said-to-not-work-well-but-i-cant-make
I can only break it if it is all 3 conditions:
It has to be function component using useState, and I have to mutate the state (which the docs says I shouldn't do), and use index as key. So if I don't mutate the state, I can't make it not work well if I use index as key.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Dokumentationsseite zur Reconciliation und dem darin verlinkten CodePen-Beispiel, und vergleiche anschließend das berichtete Verhalten mit dem verlinkten Stack-Overflow-Fall. Ermittle, ob das Beispiel oder die Erklärung einer Klarstellung bedarf, und betrachte die Dokumentation als vollständig, wenn sie einen reproduzierbaren Fall oder den Grund, warum das aktuelle Beispiel weiterhin gültig ist, korrekt erklärt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100