react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

[Mistake]: Unused key in useOptimistic code sample

Open lnicepei opened this issue 1 year ago • 1 comments
trafficstars

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}>

lnicepei avatar Jun 01 '24 07:06 lnicepei

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

Wellitsabhi avatar Jun 16 '24 15:06 Wellitsabhi