react报错:Warning: Each child in a list should have a unique “key“ prop.

文章讲述了作者在使用React的Popconfirm组件时遇到警告,发现未添加key属性导致的错误,并分享了解决方法——为组件添加key属性以避免此类问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我是万万没想到的,使用Popconfirm不添加key属性也会报错:

@react-refresh:160Warning: Each child in a list should have a unique "key" prop. Check the render method of `Cell`. Seehttps://reactjs.org/link/warning-keys for more information. athttp://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:33866:34 at Cell3 (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:37961:25) athttp://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:38077:22 at tr at BodyRow (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:38316:25) at tbody at Provider3 (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:37860:22) at Body (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:38520:19) at table at div at div athttp://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:39317:23 at div at Table (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:39327:25) at div at div at Spin2 (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:32044:25) at SpinFC2 (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:32089:34) at div at InternalTable (http://localhost:5173/node_modules/.vite/deps/chunk-2Q4JEYIA.js?v=2824dff9:43767:34) at div at div at LicenseList (http://localhost:5173/src/pages/StoreRun/serve/list/index.tsx?t=1714118344716:36:22) at InnerLoadable2 (http://localhost:5173/node_modules/.vite/deps/@loadable_component.js?v=2824dff9:155:34) at LoadableWithChunkExtractor2 at Loadable

给Popconfirm添加key属性后就好了.......

害我找了好久才找到这种神奇的bug

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

1024小神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值