Browse Source

fix: should not generate className twice, close: #5295

pull/5314/head
Benjy Cui 8 years ago
parent
commit
4579d8c419
  1. 2
      components/radio/__tests__/__snapshots__/demo.test.js.snap
  2. 2
      components/radio/demo/basic.md
  3. 8
      components/radio/radio.tsx

2
components/radio/__tests__/__snapshots__/demo.test.js.snap

@ -1,6 +1,6 @@
exports[`test renders ./components/radio/demo/basic.md correctly 1`] = `
<label
class="ant-radio-wrapper">
class="ant-radio-wrapper customized">
<span
class="ant-radio">
<input

2
components/radio/demo/basic.md

@ -16,5 +16,5 @@ The simplest use.
```jsx
import { Radio } from 'antd';
ReactDOM.render(<Radio>Radio</Radio>, mountNode);
ReactDOM.render(<Radio className="customized">Radio</Radio>, mountNode);
```

8
components/radio/radio.tsx

@ -30,11 +30,11 @@ export default class Radio extends React.Component<RadioProps, any> {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}
render() {
const { prefixCls, children, checked, disabled, className = '', style } = this.props;
const { prefixCls, className, children, style, ...restProps } = this.props;
const wrapperClassString = classNames({
[`${prefixCls}-wrapper`]: true,
[`${prefixCls}-wrapper-checked`]: checked,
[`${prefixCls}-wrapper-disabled`]: disabled,
[`${prefixCls}-wrapper-checked`]: restProps.checked,
[`${prefixCls}-wrapper-disabled`]: restProps.disabled,
}, className);
return (
@ -44,7 +44,7 @@ export default class Radio extends React.Component<RadioProps, any> {
onMouseEnter={this.props.onMouseEnter}
onMouseLeave={this.props.onMouseLeave}
>
<RcRadio {...this.props} style={null} children={null} />
<RcRadio {...restProps} prefixCls={prefixCls} />
{children !== undefined ? <span>{children}</span> : null}
</label>
);

Loading…
Cancel
Save