Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jun 1, 2024 · 11 comments

Comments

@yangjike123
Copy link

yangjike123 commented Jun 1, 2024

🐛 bug 描述

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

🏞 期望结果

不在出现这个报错提醒

💻 复现代码

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

© 版本信息

  • "@ant-design/pro-components": "^2.7.9"
  • "antd": "^5.17.3"
  • "vite": "^5.2.0"
  • "react": "^18.3.0"
  • "react-dom": "^18.3.0"
  • Microsoft Edge
  • windows11

🚑 其他信息

image
@yangjike123 yangjike123 changed the title console.js:273 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: 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: Jun 1, 2024
@fnoopv
Copy link
Contributor

fnoopv commented Jun 3, 2024

ref #8382

@yangjike123
Copy link
Author

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

@fnoopv
Copy link
Contributor

fnoopv commented Jun 7, 2024

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

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

@tangbzai
Copy link

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

@ByteTerminator
Copy link

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

@tangbzai
Copy link

貌似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
Copy link

Jackwew commented Jul 3, 2024

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

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

@zhengmenghuang
Copy link

观望

@cnTailor
Copy link

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

@resetsix
Copy link

see #8837

@wolfherder
Copy link

antd 4.24.16 观望

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants