mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
No need Radio[key] in RadioGroup
This commit is contained in:
parent
33ad640b0f
commit
16fdb00282
@ -37,10 +37,10 @@ const App = React.createClass({
|
||||
};
|
||||
return (
|
||||
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
||||
<Radio style={radioStyle} key="a" value={1}>Option A</Radio>
|
||||
<Radio style={radioStyle} key="b" value={2}>Option B</Radio>
|
||||
<Radio style={radioStyle} key="c" value={3}>Option C</Radio>
|
||||
<Radio style={radioStyle} key="d" value={4}>
|
||||
<Radio style={radioStyle} value={1}>Option A</Radio>
|
||||
<Radio style={radioStyle} value={2}>Option B</Radio>
|
||||
<Radio style={radioStyle} value={3}>Option C</Radio>
|
||||
<Radio style={radioStyle} value={4}>
|
||||
More...
|
||||
{this.state.value === 4 ? <Input style={{ width: 100, marginLeft: 10 }} /> : null}
|
||||
</Radio>
|
||||
|
@ -32,10 +32,10 @@ const App = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
||||
<Radio key="a" value={1}>A</Radio>
|
||||
<Radio key="b" value={2}>B</Radio>
|
||||
<Radio key="c" value={3}>C</Radio>
|
||||
<Radio key="d" value={4}>D</Radio>
|
||||
<Radio value={1}>A</Radio>
|
||||
<Radio value={2}>B</Radio>
|
||||
<Radio value={3}>C</Radio>
|
||||
<Radio value={4}>D</Radio>
|
||||
</RadioGroup>
|
||||
);
|
||||
},
|
||||
|
@ -84,11 +84,7 @@ export default class RadioGroup extends React.Component<RadioGroupProps, any> {
|
||||
const props = this.props;
|
||||
const children = !props.children ? [] : React.Children.map(props.children, (radio: any) => {
|
||||
if (radio && (radio.type === Radio || radio.type === RadioButton) && radio.props) {
|
||||
const keyProps = {};
|
||||
if (!('key' in radio) && typeof radio.props.value === 'string') {
|
||||
(keyProps as any).key = radio.props.value;
|
||||
}
|
||||
return React.cloneElement(radio, assign({}, keyProps, radio.props, {
|
||||
return React.cloneElement(radio, assign({}, radio.props, {
|
||||
onChange: this.onRadioChange,
|
||||
checked: this.state.value === radio.props.value,
|
||||
disabled: radio.props.disabled || this.props.disabled,
|
||||
|
Loading…
Reference in New Issue
Block a user