Replies: 5 comments 16 replies
-
cc @ant-design/ant-design-collaborators |
Beta Was this translation helpful? Give feedback.
0 replies
-
这里的 <Form.List name="users">
{fields => (
<MyField key={field.key} field={field} />
)}
</Form.List>
MyField = () => {
const parentPath = Form.useNamePath(); // users
const myPath = [...parentPath, field.name]; // [users, number]
}; 而对 FormItem,这个看起来抽象度还不够。如果是专门包一个 Form.Scope 还要提供 name 这个就很怪异。还要想想 Form.Item 下嵌套场景是否有更好的形式。 |
Beta Was this translation helpful? Give feedback.
10 replies
-
我目前是这样用的, const List = (props: FormListProps) => {
const { name } = props;
const context = useContext(FieldContext);
const { prefixName } = context;
const fieldContext = useMemo(
() => ({ ...context, prefixName: prefixName ? concat(prefixName, name) : name }),
[context, name, prefixName]
);
return (
<FieldContext.Provider value={fieldContext}>
<Form.List {...props} />
</FieldContext.Provider>
);
};
export default List;
const { prefixName } = useContext(FieldContext);
const allName = prefixName ? concat(prefixName, name) : name; |
Beta Was this translation helpful? Give feedback.
2 replies
-
是不是提供一个
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
📋 RFC
Summary
问题:
Form.List
可以向下传递NamePath
,Form.List
下的Item只能写成name={[field.name, 'name']}
,写法很繁琐;目的:
Example
希望可以这样使用:
Beta Was this translation helpful? Give feedback.
All reactions