ant-design / ant-design/pro-components

🧐[问题]renderFormItem中应该如何正确消费request返回的数据

Open
#8,512 0 comments 0 reactions 0 assignees View on GitHub
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 (





);
},
},
```
### 🚑 其他信息

image

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.