zl程序教程

您现在的位置是:首页 >  后端

当前栏目

react列表key满足这些条件可以直接使用数组索引

列表索引数组React 可以 Key 条件 直接
2023-09-27 14:28:05 时间
  1. the list and items are static–they are not computed and do not change;
  2. the items in the list have no ids;
  3. the list is never reordered or filtered.

When all of them are met, you may safely use the index as a key.

 

参考:Index as a key is an anti-pattern (React) | by Robin Pokorny | Medium