Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
问题描述:
在Antd Form 组件中使用自定义 Function component时提示以上警告错误。
解决办法:
使用 forwardRef 包裹函数组件
import React, { forwardRef } from 'react';
const MyFunctionComponent = forwardRef((props, _ref) => {
return <div> something here ......</div>
}