ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.26k stars 1.35k forks source link

Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: #8464

Open yangjike123 opened 4 months ago

yangjike123 commented 4 months ago

🐛 bug 描述

只要ProTable组件渲染完毕后就会爆出这个提醒

image

🏞 期望结果

不在出现这个报错提醒

💻 复现代码

仓库地址:https://github.com/yangjike123/template.git

© 版本信息

🚑 其他信息

image
fnoopv commented 4 months ago

ref #8382

yangjike123 commented 3 months ago

你好,有修复这个问题的计划吗?或者是有可以手动去解决 @fnoopv

fnoopv commented 3 months ago

你好,有修复这个问题的计划吗?或者是有可以手动去解决 @fnoopv

rc-util库的问题,只能等他们修,别的没办法

tangbzai commented 3 months ago

貌似Tooltip的children渲染为null时会出现该警告#48709 这种情况可以在这个库使用Tooltip时避免

ByteTerminator commented 3 months ago

"antd": "4.24.15",
"react": "18.2.0", "react-dom": "18.2.0", 锁版本解决了这个问题,node16.20.2 npm8.19.4

tangbzai commented 3 months ago

貌似Tooltip的children渲染为null时会出现该警告#48709 这种情况可以在这个库使用Tooltip时避免

ant-design官方文档的解释

为何在严格模式中有时候会出现 findDOMNode is deprecated 这个警告? 这是由于 rc-trigger 的实现方式导致的,rc-trigger 强制要求 children 能够接受 ref,否则就会 fallback 到 findDOMNode,所以 children 需要是原生 html 标签,如果不是,则需要使用 React.forwardRef 把 ref 透传到原生 html 标签。

另外我在使用 umi-plugin-layout 的菜单也出现了这个问题
导致问题的代码位置

umi-plugin-layoutmenuItemRender 返回了一个 umiLink组件 代码位置
然后 pro-componentsMenuItemTooltip 直接用 Tooltip 包住了返回的 Link 组件 代码位置

上述代码导致 Tooltip 直接包住了一个不能够接受 refLink,所以出现了这个问题

可能的改进办法
  1. MenuItemTooltipprops.children外包一层可接受 ref 的标签
  2. umi-plugin-layoutmenuItemRender返回的 Link 组件外包一层可接受 ref 的标签
* 因为这个问题涉及到两个库,我不太确定应该在哪边改,应该只需要修改一个地方就能解决这个问题
Jackwew commented 3 months ago

"antd": "4.24.15", "react": "18.2.0", "react-dom": "18.2.0", 锁版本解决了这个问题,node16.20.2 npm8.19.4

这个不是pro-components的错误么,你锁了antd的版本就没问题了?

zhengmenghuang commented 1 month ago

观望

cnTailor commented 1 week ago

rc-resize-observer 这个库1年没怎么维护了,赶紧替换掉吧