reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
10.98k stars 7.5k forks source link

[Mistake]: Unused key in useOptimistic code sample #6926

Open lnicepei opened 3 months ago

lnicepei commented 3 months ago

Summary

The code example for useOptimistic hook contains unused key parameter

Page

https://19.react.dev/reference/react/useOptimistic#usage

Details

In the Optimistically updating forms section, inside the code sample there is an unused key parameter, which, apparently, should have been used on the line 25:

<div key={index}>
Wellitsabhi commented 3 months ago

It's not a mistake, 'key' parameter is used in reconciliation to optimize render performance . And it's right way of writing code when using .map