mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
docs(radio): change demo to hook (#27722)
This commit is contained in:
parent
3ad1887fff
commit
7b6bb4244d
@ -16,29 +16,23 @@ A group of radio components.
|
|||||||
```jsx
|
```jsx
|
||||||
import { Radio } from 'antd';
|
import { Radio } from 'antd';
|
||||||
|
|
||||||
class App extends React.Component {
|
const App = () => {
|
||||||
state = {
|
const [value, setValue] = React.useState(1);
|
||||||
value: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
onChange = e => {
|
const onChange = e => {
|
||||||
console.log('radio checked', e.target.value);
|
console.log('radio checked', e.target.value);
|
||||||
this.setState({
|
setValue(e.target.value);
|
||||||
value: e.target.value,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
return (
|
||||||
return (
|
<Radio.Group onChange={onChange} value={value}>
|
||||||
<Radio.Group onChange={this.onChange} value={this.state.value}>
|
<Radio value={1}>A</Radio>
|
||||||
<Radio value={1}>A</Radio>
|
<Radio value={2}>B</Radio>
|
||||||
<Radio value={2}>B</Radio>
|
<Radio value={3}>C</Radio>
|
||||||
<Radio value={3}>C</Radio>
|
<Radio value={4}>D</Radio>
|
||||||
<Radio value={4}>D</Radio>
|
</Radio.Group>
|
||||||
</Radio.Group>
|
);
|
||||||
);
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactDOM.render(<App />, mountNode);
|
ReactDOM.render(<App />, mountNode);
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user