ant-design/components/segmented/demo/dynamic.md
vagusX eee3b50727
feat: support icon only in segmented (#35256)
* feat: support icon only with segmented

* fix: lint issue

* chore: update

* test: fix

* test: update snapshot
2022-04-28 19:39:52 +08:00

788 B

order title
5
zh-CN en-US
动态数据 Dynamic

zh-CN

动态加载数据。

en-US

Load options dynamically.

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;