From b83aaed358d7d4341f3619b34e5ec9f7ed9ee985 Mon Sep 17 00:00:00 2001 From: Leon Shi Date: Sun, 12 Jun 2016 16:15:11 +0800 Subject: [PATCH] improve Radio re-render performance --- components/radio/group.jsx | 4 ++++ components/radio/radio.jsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/radio/group.jsx b/components/radio/group.jsx index 48ae8f9a57..bd2b748125 100644 --- a/components/radio/group.jsx +++ b/components/radio/group.jsx @@ -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({ diff --git a/components/radio/radio.jsx b/components/radio/radio.jsx index 2afda2ea75..5722f39f93 100644 --- a/components/radio/radio.jsx +++ b/components/radio/radio.jsx @@ -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({