Skip to content

Commit

Permalink
Merge pull request #9 from JackWang032/feat/formInstance
Browse files Browse the repository at this point in the history
feat(core): allow collect from fieldsValue in props formInstance
  • Loading branch information
HaydenOrz authored Nov 28, 2023
2 parents e0ba16c + 0875da8 commit 11753c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/FormRenderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
### ref

通过 ref 可以拿到 FormRenderer 内部的 ant-design form 实例。

### form

如果传入了 form 实例,则 FormRenderer 内部不会再创建新的 form 实例,数据都将收集在传入的 form 中,也就无需再通过 ref 去访问表单数据了。注意:传入的 form 实例必须是在 `Form.useForm()` 中创建的,不要使用类组件中通过 ref 创建的实例。
3 changes: 2 additions & 1 deletion packages/core/src/components/formRenderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ const FormRenderer: React.ForwardRefRenderFunction<
header,
footer,
debounceSearch,
form: formInstance,
...restProps
} = props;
const [form] = useForm();
const [form] = useForm(formInstance);
const [extraDataRef, updateExtraData] = useExtraData({
serviceLoading: {},
});
Expand Down

0 comments on commit 11753c4

Please sign in to comment.