mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 13:47:02 +08:00
Merge pull request #2007 from ant-design/perf-form
refactor: improve Form re-render performance
This commit is contained in:
commit
3bd90d9b70
@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
|
||||
export default class Form extends React.Component {
|
||||
static defaultProps = {
|
||||
@ -22,6 +23,10 @@ export default class Form extends React.Component {
|
||||
form: React.PropTypes.object,
|
||||
}
|
||||
|
||||
shouldComponentUpdate(...args) {
|
||||
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||
}
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
form: this.props.form,
|
||||
|
@ -1,9 +1,6 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
function prefixClsFn(prefixCls, ...args) {
|
||||
return args.map((s) => `${prefixCls}-${s}`).join(' ');
|
||||
}
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
|
||||
export default class FormItem extends React.Component {
|
||||
static defaultProps = {
|
||||
@ -28,6 +25,10 @@ export default class FormItem extends React.Component {
|
||||
form: React.PropTypes.object,
|
||||
}
|
||||
|
||||
shouldComponentUpdate(...args) {
|
||||
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||
}
|
||||
|
||||
getLayoutClass(colDef) {
|
||||
if (!colDef) {
|
||||
return '';
|
||||
@ -70,11 +71,10 @@ export default class FormItem extends React.Component {
|
||||
}
|
||||
|
||||
renderHelp() {
|
||||
const props = this.props;
|
||||
const prefixCls = props.prefixCls;
|
||||
const prefixCls = this.props.prefixCls;
|
||||
const help = this.getHelpMsg();
|
||||
return help ? (
|
||||
<div className={prefixClsFn(prefixCls, 'explain')} key="help">
|
||||
<div className={`${prefixCls}-explain`} key="help">
|
||||
{help}
|
||||
</div>
|
||||
) : null;
|
||||
@ -83,7 +83,7 @@ export default class FormItem extends React.Component {
|
||||
renderExtra() {
|
||||
const { prefixCls, extra } = this.props;
|
||||
return extra ? (
|
||||
<span className={prefixClsFn(prefixCls, 'extra')}>{extra}</span>
|
||||
<span className={`${prefixCls}-extra`}>{extra}</span>
|
||||
) : null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user