mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
Merge pull request #1992 from ant-design/should-component-update-for-checkbox
Checkbox: implement shouldComponentUpdate to make the re-render much faster
This commit is contained in:
commit
c1ac6917ee
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Checkbox from './index';
|
import Checkbox from './index';
|
||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
|
||||||
export default class CheckboxGroup extends React.Component {
|
export default class CheckboxGroup extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@ -30,6 +31,9 @@ export default class CheckboxGroup extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
shouldComponentUpdate(...args) {
|
||||||
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||||
|
}
|
||||||
getOptions() {
|
getOptions() {
|
||||||
const { options } = this.props;
|
const { options } = this.props;
|
||||||
return options.map(option => {
|
return options.map(option => {
|
||||||
|
@ -2,12 +2,16 @@ import RcCheckbox from 'rc-checkbox';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import CheckboxGroup from './Group';
|
import CheckboxGroup from './Group';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
|
||||||
export default class Checkbox extends React.Component {
|
export default class Checkbox extends React.Component {
|
||||||
static Group = CheckboxGroup;
|
static Group = CheckboxGroup;
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
prefixCls: 'ant-checkbox',
|
prefixCls: 'ant-checkbox',
|
||||||
}
|
}
|
||||||
|
shouldComponentUpdate(...args) {
|
||||||
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
const { prefixCls, style, children, className, ...restProps } = this.props;
|
const { prefixCls, style, children, className, ...restProps } = this.props;
|
||||||
const classString = classNames({
|
const classString = classNames({
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
"rc-upload": "~1.13.0",
|
"rc-upload": "~1.13.0",
|
||||||
"rc-util": "~3.1.3",
|
"rc-util": "~3.1.3",
|
||||||
"react-slick": "~0.12.0",
|
"react-slick": "~0.12.0",
|
||||||
|
"react-addons-pure-render-mixin": "~15.1.0",
|
||||||
"warning": "~3.0.0"
|
"warning": "~3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user