improve Radio re-render performance

This commit is contained in:
Leon Shi 2016-06-12 16:15:11 +08:00
parent a69b7b70a1
commit b83aaed358
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import Radio from './radio';
import RadioButton from './radioButton';
import PureRenderMixin from 'react-addons-pure-render-mixin';
function getCheckedValue(children) {
let value = null;
@ -51,6 +52,9 @@ export default class RadioGroup extends React.Component {
}
}
}
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}
onRadioChange = (ev) => {
if (!('value' in this.props)) {
this.setState({

View File

@ -1,11 +1,15 @@
import RcRadio from 'rc-radio';
import React from 'react';
import classNames from 'classnames';
import PureRenderMixin from 'react-addons-pure-render-mixin';
export default class Radio extends React.Component {
static defaultProps = {
prefixCls: 'ant-radio',
}
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}
render() {
const { prefixCls, children, checked, disabled, className, style } = this.props;
const classString = classNames({