mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
improve Radio re-render performance
This commit is contained in:
parent
a69b7b70a1
commit
b83aaed358
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Radio from './radio';
|
import Radio from './radio';
|
||||||
import RadioButton from './radioButton';
|
import RadioButton from './radioButton';
|
||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
|
||||||
function getCheckedValue(children) {
|
function getCheckedValue(children) {
|
||||||
let value = null;
|
let value = null;
|
||||||
@ -51,6 +52,9 @@ export default class RadioGroup extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
shouldComponentUpdate(...args) {
|
||||||
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||||
|
}
|
||||||
onRadioChange = (ev) => {
|
onRadioChange = (ev) => {
|
||||||
if (!('value' in this.props)) {
|
if (!('value' in this.props)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import RcRadio from 'rc-radio';
|
import RcRadio from 'rc-radio';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
|
||||||
export default class Radio extends React.Component {
|
export default class Radio extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
prefixCls: 'ant-radio',
|
prefixCls: 'ant-radio',
|
||||||
}
|
}
|
||||||
|
shouldComponentUpdate(...args) {
|
||||||
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
const { prefixCls, children, checked, disabled, className, style } = this.props;
|
const { prefixCls, children, checked, disabled, className, style } = this.props;
|
||||||
const classString = classNames({
|
const classString = classNames({
|
||||||
|
Loading…
Reference in New Issue
Block a user