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
|
||||
import { Radio } from 'antd';
|
||||
|
||||
class App extends React.Component {
|
||||
state = {
|
||||
value: 1,
|
||||
};
|
||||
const App = () => {
|
||||
const [value, setValue] = React.useState(1);
|
||||
|
||||
onChange = e => {
|
||||
const onChange = e => {
|
||||
console.log('radio checked', e.target.value);
|
||||
this.setState({
|
||||
value: e.target.value,
|
||||
});
|
||||
setValue(e.target.value);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Radio.Group onChange={this.onChange} value={this.state.value}>
|
||||
<Radio value={1}>A</Radio>
|
||||
<Radio value={2}>B</Radio>
|
||||
<Radio value={3}>C</Radio>
|
||||
<Radio value={4}>D</Radio>
|
||||
</Radio.Group>
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Radio.Group onChange={onChange} value={value}>
|
||||
<Radio value={1}>A</Radio>
|
||||
<Radio value={2}>B</Radio>
|
||||
<Radio value={3}>C</Radio>
|
||||
<Radio value={4}>D</Radio>
|
||||
</Radio.Group>
|
||||
);
|
||||
};
|
||||
|
||||
ReactDOM.render(<App />, mountNode);
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user