fix: Form.Item init status should also check help (#21211)

* fix: Form.Item init status should also check help

* clean up
This commit is contained in:
二货机器人 2020-02-04 14:43:12 +08:00 committed by GitHub
parent 536823b977
commit ad51283a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<Record<string, string[]>>({});
const { name: formName } = formContext;