我正在使用antd,并且看到此错误
findDOMNode在StrictMode中已弃用。 findDOMNode传递了StrictMode内部的DOMWrap实例。相反,直接将引用添加到要引用的元素
我已经意识到这是由于mode="horizontal"
造成的。
我也尝试使用其他组件,并且在antd中经常看到此错误。有什么办法可以解决此问题?
这是我当前的代码
import React from 'react'
import { connect } from 'react-redux';
import { Layout, Menu } from 'antd';
const { Header, Footer, Content } = Layout;
const AddForm = () => {
return (
<div>
{/* // Menu Starts from here */}
<Layout className="layout">
<Header>
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
<Menu.Item key="1">nav 1</Menu.Item>
<Menu.Item key="2">nav 2</Menu.Item>
<Menu.Item key="3">nav 3</Menu.Item>
</Menu>
</Header>
<Content style={{ padding: '0 50px' }}>
<div className="site-layout-content">Content</div>
</Content>
<Footer style={{ textAlign: 'center' }}>Ant Design ©2018 Created by Ant UED</Footer>
</Layout>
</div>
)
};
答案 0 :(得分:0)
在React 16:https://github.com/ant-design/ant-design/issues/22493
中,findDOMNode
没有很好的选择
答案 1 :(得分:0)
对此您无能为力。您必须等待 app:icon
支持严格模式。不过,您可以考虑为该项目做出贡献。
答案 2 :(得分:0)
我正在通过使用
就我而言,表单内的按钮导致了该错误,所以我通过
解决了它<React.StrictMode>
<Button type="primary" htmlType="submit" className="submit">
Register
</Button>
</React.StrictMode>