mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 20:19:44 +08:00
chore: use purecomponent replace shallow compare (#21575)
This commit is contained in:
parent
2f91dd4925
commit
55133b7757
@ -1,7 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import * as PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import shallowEqual from 'shallowequal';
|
||||
import omit from 'omit.js';
|
||||
import Checkbox, { CheckboxChangeEvent } from './Checkbox';
|
||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
@ -48,7 +47,7 @@ export const GroupContext = React.createContext<{ checkboxGroup: any }>({
|
||||
checkboxGroup: undefined,
|
||||
});
|
||||
|
||||
class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupState> {
|
||||
class CheckboxGroup extends React.PureComponent<CheckboxGroupProps, CheckboxGroupState> {
|
||||
static defaultProps = {
|
||||
options: [],
|
||||
};
|
||||
@ -77,10 +76,6 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: CheckboxGroupProps, nextState: CheckboxGroupState) {
|
||||
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
||||
}
|
||||
|
||||
getOptions() {
|
||||
const { options } = this.props;
|
||||
// https://github.com/Microsoft/TypeScript/issues/7960
|
||||
|
@ -1,7 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import * as PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import shallowEqual from 'shallowequal';
|
||||
import Radio from './radio';
|
||||
import {
|
||||
RadioGroupProps,
|
||||
@ -24,7 +23,7 @@ function getCheckedValue(children: React.ReactNode) {
|
||||
return matched ? { value } : undefined;
|
||||
}
|
||||
|
||||
class RadioGroup extends React.Component<RadioGroupProps, RadioGroupState> {
|
||||
class RadioGroup extends React.PureComponent<RadioGroupProps, RadioGroupState> {
|
||||
static defaultProps = {
|
||||
buttonStyle: 'outline' as RadioGroupButtonStyle,
|
||||
};
|
||||
@ -76,10 +75,6 @@ class RadioGroup extends React.Component<RadioGroupProps, RadioGroupState> {
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: RadioGroupProps, nextState: RadioGroupState) {
|
||||
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
||||
}
|
||||
|
||||
onRadioChange = (ev: RadioChangeEvent) => {
|
||||
const lastValue = this.state.value;
|
||||
const { value } = ev.target;
|
||||
|
Loading…
Reference in New Issue
Block a user