mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 23:35:38 +08:00
27 lines
641 B
TypeScript
27 lines
641 B
TypeScript
|
import React, { useState } from 'react';
|
||
|
import { Segmented, Button } from 'antd';
|
||
|
|
||
|
const defaultOptions = ['Daily', 'Weekly', 'Monthly'];
|
||
|
|
||
|
const Demo: React.FC = () => {
|
||
|
const [options, setOptions] = useState(defaultOptions);
|
||
|
const [moreLoaded, setMoreLoaded] = useState(false);
|
||
|
|
||
|
const handleLoadOptions = () => {
|
||
|
setOptions([...defaultOptions, 'Quarterly', 'Yearly']);
|
||
|
setMoreLoaded(true);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Segmented options={options} />
|
||
|
<br />
|
||
|
<Button type="primary" disabled={moreLoaded} onClick={handleLoadOptions}>
|
||
|
Load more options
|
||
|
</Button>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default Demo;
|