Skip to content

Commit 0875da8

Browse files
author
jialan
committed
feat(core): allow collect from fieldsValue in props formInstance
1 parent e0ba16c commit 0875da8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/FormRenderer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@
3737
### ref
3838

3939
通过 ref 可以拿到 FormRenderer 内部的 ant-design form 实例。
40+
41+
### form
42+
43+
如果传入了 form 实例,则 FormRenderer 内部不会再创建新的 form 实例,数据都将收集在传入的 form 中,也就无需再通过 ref 去访问表单数据了。注意:传入的 form 实例必须是在 `Form.useForm()` 中创建的,不要使用类组件中通过 ref 创建的实例。

packages/core/src/components/formRenderer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ const FormRenderer: React.ForwardRefRenderFunction<
6161
header,
6262
footer,
6363
debounceSearch,
64+
form: formInstance,
6465
...restProps
6566
} = props;
66-
const [form] = useForm();
67+
const [form] = useForm(formInstance);
6768
const [extraDataRef, updateExtraData] = useExtraData({
6869
serviceLoading: {},
6970
});

0 commit comments

Comments
 (0)