From 406f9fb9941863ac02f9817c1a9f91b4252787f8 Mon Sep 17 00:00:00 2001 From: Janry Date: Sat, 11 Jan 2020 22:35:05 +0800 Subject: [PATCH] fix(@uform/core): fix submit catch error (#603) * fix(@uform/core): fix submit catch error * fix(@uform/core): fix ci * fix(@uform/core): fix ci --- docs/Examples/antd/Layout.md | 91 ------------------- packages/core/src/index.ts | 6 +- .../src/shared/connect.ts | 9 +- 3 files changed, 8 insertions(+), 98 deletions(-) diff --git a/docs/Examples/antd/Layout.md b/docs/Examples/antd/Layout.md index 9d5586fecac..99a6f0f4f35 100644 --- a/docs/Examples/antd/Layout.md +++ b/docs/Examples/antd/Layout.md @@ -272,97 +272,6 @@ ReactDOM.render(, document.getElementById('root')) ## 分步表单 -```jsx -import { - SchemaForm, - SchemaMarkupField as Field, - FormButtonGroup, - Submit, - FormEffectHooks, - createFormActions, - FormGridRow, - FormItemGrid, - FormGridCol, - FormPath, - FormLayout, - FormBlock, - FormCard, - FormTextBox, - FormStep -} from '@uform/antd' -import { Button } from 'antd' -import 'antd/dist/antd.css' - -const { onFormInit$ } = FormEffectHooks - -const actions = createFormActions() - -let cache = {} - -export default () => ( - { - console.log('提交') - console.log(values) - }} - actions={actions} - labelCol={{ span: 8 }} - wrapperCol={{ span: 6 }} - validateFirst - effects={({ setFieldState, getFormGraph }) => { - onFormInit$().subscribe(() => { - setFieldState('col1', state => { - state.visible = false - }) - }) - }} - > - - - - - - - - - - - - 提交 - - - - - - -) -``` - -## FormStep - > 分步表单,主要用于大量表单填写,需要区分步骤的场景,使用FormStep和FormSpy #### Demo 示例 diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 12b8dff9e02..d8297754e20 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -901,9 +901,9 @@ export function createForm( try { payload = await Promise.resolve(onSubmit(values)) } catch (e) { - if (e) { - console.error(e) - } + new Promise(() => { + throw e + }) } } diff --git a/packages/react-schema-renderer/src/shared/connect.ts b/packages/react-schema-renderer/src/shared/connect.ts index 18a89f5222b..5c7451141dd 100644 --- a/packages/react-schema-renderer/src/shared/connect.ts +++ b/packages/react-schema-renderer/src/shared/connect.ts @@ -43,12 +43,13 @@ const bindEffects = ( (event, key) => { const prevEvent = key === 'onChange' ? props[key] : undefined props[key] = (...args: any[]) => { - if (isFn(prevEvent)) { - prevEvent(...args) - } if (isFn(event)) { - return event(...args) + event(...args) + } + if (isFn(prevEvent)) { + return prevEvent(...args) } + } } )