Reproduction link
Steps to reproduce
点击2次切换,控制台报错
Warning: Encountered two children with the same key, `xxx`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
What is expected?
不报错
What is actually happening?
报错
| Environment | Info |
| ------------ | ------------ |
| antd | 5.19.3 |
| React | latest |
| System | mac |
| Browser | chrome |
4条答案
按热度按时间piv4azn71#
Start a new pull request in StackBlitz Codeflow .
jq6vz3qz2#
相同报错切换类型这种不常见,但是 warning 和 error 的确可以加个 prefix 来避免一下。
mhd8tkvw3#
相同报错切换类型这种不常见,但是 warning 和 error 的确可以加个 prefix 来避免一下。
我为什么能调出来,是因为目前一个需求,名称校验,接口返回的 type 1 是警告,type 2 是报错。
zhte4eai4#
我调试发现,切换还会跳一下,如果 warning 跟 error 是一个元素,只是 className 不同会不会好些?