-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
findDOMNode is deprecated and will be removed in the next major release. #8752
Comments
在 Ant Design 的 GitHub 仓库中,确实有一些与
你可以参考这些问题和 PR,看看是否有解决方案适用于你的情况。 通常情况下,解决这个问题的方法是避免使用 如果你有进一步的问题,请在评论中描述并 @petercat-assistant 以开始与我对话。 |
Hello @yuzh0816. Please provide a online reproduction by forking this one or provide a minimal GitHub repository like create-react-app-antd. Issues labeled by 你好 @yuzh0816,我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过 fork 这个在线重现案例 ,或者提供一个最小化的 GitHub 仓库(类似 create-react-app-antd)。3 天内未跟进此 issue 将会被自动关闭。 |
目前没有找到与 以下是一个简单的示例,展示了如何将 之前的代码:import ReactDOM from 'react-dom';
class MyComponent extends React.Component {
componentDidMount() {
const node = ReactDOM.findDOMNode(this);
// 你的逻辑
}
render() {
return <div>My Component</div>;
}
} 修改后的代码:import React from 'react';
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
}
componentDidMount() {
const node = this.myRef.current;
// 你的逻辑
}
render() {
return <div ref={this.myRef}>My Component</div>;
}
} 你可以在你的项目中查找所有使用 如果你在修改过程中遇到任何问题,请随时在评论中描述你的问题并 @petercat-assistant 与我进行对话。 For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
麻烦您重新测试下刚刚的仓库,我更新了下package信息,将react版本切换至了18.3.1,问题即可复现。 |
看上去是 ProLayout 的实现问题。 |
以下的 Issues 可能会帮助到你 / The following issues may help you
|
使用 ProTable 也报这个错误 版本信息 使用方式 import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
<ProTable /> 注释掉 就不报错 浏览器报错信息 解决方案之一 "react": "18.2.0", |
see #8837 |
Reproduction link
https://github.com/yuzh0816/antd-test
Steps to reproduce
执行npm run dev后,打开控制台即可看到报错
What is expected?
希望这处报错被解决。
What is actually happening?
报错:
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.
The text was updated successfully, but these errors were encountered: