From 0187384445362a1f46ef1417f92771ef01182b26 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 6 Jan 2017 01:33:09 +0800 Subject: [PATCH] refactor for code style --- components/form/FormItem.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 085112d9ca..f8ae9991a2 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -195,6 +195,10 @@ export default class FormItem extends React.Component { } isRequired() { + const { required } = this.props; + if (required !== undefined) { + return required; + } if (this.context.form) { const meta = this.getMeta() || {}; const validate = (meta.validate || []); @@ -209,9 +213,7 @@ export default class FormItem extends React.Component { renderLabel() { const props = this.props; const labelCol = props.labelCol; - const required = props.required === undefined ? - this.isRequired() : - props.required; + const required = this.isRequired(); const className = classNames({ [`${props.prefixCls}-item-required`]: required,