From be680e0274bafa8bd60e758ac4a939d7c0da60ab Mon Sep 17 00:00:00 2001 From: janryWang Date: Mon, 6 May 2019 17:46:54 +0800 Subject: [PATCH] fix(@uform/core): Optimize the 'errors' information structure --- docs/API/Submit.md | 1 + packages/core/src/form.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/API/Submit.md b/docs/API/Submit.md index 269a1b39b41..638d6e4bd74 100644 --- a/docs/API/Submit.md +++ b/docs/API/Submit.md @@ -18,6 +18,7 @@ import { Submit } from '@uform/next(antd)' 扩展属性 - showLoading : Boolean + > 主要用于控制Submit组件是否自动展示loading图标,要求SchemaForm的onSubmit回调必须返回Promise对象才会生效。 ## 用例 diff --git a/packages/core/src/form.js b/packages/core/src/form.js index f5bbb48742e..268d7730514 100644 --- a/packages/core/src/form.js +++ b/packages/core/src/form.js @@ -294,8 +294,9 @@ export class Form { const lastValid = this.state.valid let _errors = reduce( response, - (buf, { valid, errors }) => { - return buf.concat(errors) + (buf, { name, errors }) => { + if (!errors.length) return buf + return buf.concat({ name, errors }) }, [] )