ant-design / ant-design/pro-components
🧐[问题]renderFormItem中应该如何正确消费request返回的数据
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
### 🧐 问题描述
renderFormItem中应该如何正确消费request返回的数据?
以下代码能正常运行 ,但是TS报错
### 💻 示例代码
```jsx
{
title: '分配菜单',
dataIndex: 'menus',
valueType: 'option',
hideInTable: true,
hideInSearch: true,
formItemProps: {
tooltip: '分配菜单',
rules: [
{
required: true,
message: '选择菜单',
},
],
},
request: async () => {
console.log('request treeDataList:', treeDataList)
return treeDataList;
},
renderFormItem: (schema, config, form) => {
const onCheck: TreeProps['onCheck'] = (checkedKeysValue) => {
form.setFieldsValue({ menus: checkedKeysValue });
};
const keys = form.getFieldValue('menus') || [];
return (
);
},
},
```
### 🚑 其他信息
Contributor guide
Research direction
Start by reviewing the renderFormItem and request usage in the issue example, then reproduce the TypeScript error with the shown configuration. Determine the expected shape passed through config.option and document or verify the corrected data consumption once the reported type error is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100