import React, { useState } from 'react';
import { Switch } from '@easyv/antd';

export default function SwitchWithLoading({ onChange, ...props }) {
  const [loading, setLoading] = useState(false);

  const handleChange = async (value) => {
    setLoading(true);
    await onChange(value);
    setLoading(false);
  };

  return <Switch loading={loading} onChange={handleChange} {...props} />;
}
