From ad51283a9db65f188398312d074aa7adc5f4613f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 4 Feb 2020 14:43:12 +0800 Subject: [PATCH] fix: Form.Item init status should also check help (#21211) * fix: Form.Item init status should also check help * clean up --- components/form/FormItem.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 9859f6ba53..9a31398e56 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -3,7 +3,7 @@ import isEqual from 'lodash/isEqual'; import classNames from 'classnames'; import { Field, FormInstance } from 'rc-field-form'; import { FieldProps } from 'rc-field-form/lib/Field'; -import {Meta, NamePath} from 'rc-field-form/lib/interface'; +import { Meta, NamePath } from 'rc-field-form/lib/interface'; import omit from 'omit.js'; import Row from '../grid/row'; import { ConfigContext } from '../config-provider'; @@ -42,11 +42,7 @@ export interface FormItemProps function hasValidName(name?: NamePath): Boolean { if (name === null) { - warning( - false, - 'Form.Item', - '`null` is passed as `name` property', - ); + warning(false, 'Form.Item', '`null` is passed as `name` property'); } return !(name === undefined || name === null); } @@ -74,7 +70,7 @@ function FormItem(props: FormItemProps): React.ReactElement { const { getPrefixCls } = React.useContext(ConfigContext); const formContext = React.useContext(FormContext); const { updateItemErrors } = React.useContext(FormItemContext); - const [domErrorVisible, setDomErrorVisible] = React.useState(false); + const [domErrorVisible, setDomErrorVisible] = React.useState(!!help); const [inlineErrors, setInlineErrors] = React.useState>({}); const { name: formName } = formContext;