ant-design / ant-design/pro-components
🐛[BUG] `ProForm`中无论用哪种方式获取`ref`, `getFieldInstance()`搭配`ProFormFields`组件永远是`undefined`
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
### 🐛 bug 描述
详见 https://github.com/ant-design/pro-components/issues/5667, https://github.com/ant-design/pro-components/issues/6648, 是完全相同的问题, 但其中的提供的解法没有任何一个是有用的.
无论使用以下那种,只要调用`getFieldInstance`尝试拿``的实例, 一律是`undefined`。
```ts
type MyFormData = { /* ... */ };
const [form] = Form.useForm();
const formRef = useRef>(null);
const [form] = ProForm.useForm();
const form = ProForm.useFormInstance();
```
全都是`undefined`. 没试过 ``行不行,但看上面的好像是可以。 麻烦看看能不能修复下。
我目前的方案是给里面的`Input`设置Ref, 但这样 `getFieldInstance()` 不就完全没有意义了么。

### 📷 复现步骤
Refer to https://github.com/ant-design/pro-components/issues/5667, https://github.com/ant-design/pro-components/issues/6648
### 🏞 期望结果
应该能拿到field的instance
### 💻 复现代码
Refer to https://github.com/ant-design/pro-components/issues/5667, https://github.com/ant-design/pro-components/issues/6648
### © 版本信息
- ProComponents 版本: ^2.6.43
- umi 版本: N/A
- 浏览器环境: Chrome 120
- 开发环境: Chrome 120
### 🚑 其他信息
希望找时间看一下,因为目前没有任何一个提供的解法是有效的,谢谢。
Contributor guide
Research direction
Start with the ProFormFields and ProFormText reproduction described here, then compare the referenced issues 5667 and 6648. Check how getFieldInstance is expected to behave with each listed form access method and verify the result against Form.Item. Done means the ProForm field instance is returned instead of undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100