React adding a key value to a node does not take effect

effect description: each time you add the + button, you can add a new row of new columns, and click the following to delete the row.

clipboard.png
:,.

:
clipboard.png

cause analysis: react"s diff algorithm needs to add key values to nodes to recognize different nodes, so add key values to nodes.
result: adding key values is still invalid.

Mar.10,2021

index is not allowed, because the current key has been refreshed before diff.
you can take a look at my blog
uses WeakMap to assign objects in Vue's new array: key


when adding, generate a unique key, for the newly added object. Do not use index.

{key: Date.now()}

  1. add a id attribute to each item in data . Each time you click the + button to add a new line, set the id of the row corresponding to item to Date.now () ;
  2. .
  3. change < div key= {String (index*44)} > to < div key= {item.id} > ;
  4. change < InputNumber key= {String (index*34)} > to < InputNumber > (not key ).
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdb8ad-31271.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdb8ad-31271.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?