diff --git a/src/client/components/AutoLoadingButton.tsx b/src/client/components/AutoLoadingButton.tsx new file mode 100644 index 0000000..8285ccd --- /dev/null +++ b/src/client/components/AutoLoadingButton.tsx @@ -0,0 +1,17 @@ +import { Button, ButtonProps } from 'antd'; +import React, { useState } from 'react'; +import { useEvent } from '../hooks/useEvent'; + +export const AutoLoadingButton: React.FC = React.memo((props) => { + const [loading, setLoading] = useState(false); + + const handleClick = useEvent( + async (e: React.MouseEvent) => { + setLoading(true); + await props.onClick?.(e); + setLoading(false); + } + ); + return