import { Switch } from 'antd'; import type { SwitchProps } from 'antd'; import { memo, useCallback, useState } from 'react'; interface CustomSwitchProps extends SwitchProps { checked: boolean; onChange?: (val: boolean) => void; } const CustomSwitch = ({ checked: value, onChange, ...others }: CustomSwitchProps) => { const [checked, setChecked] = useState(value); const changeHander = useCallback( (val: boolean) => { setChecked(val); onChange?.(val); }, [onChange], ); return ; }; export default memo(CustomSwitch);