mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-08 06:19:15 -05:00
26 lines
609 B
TypeScript
26 lines
609 B
TypeScript
import { useState } from 'react';
|
|
import type { ButtonProps } from './Button';
|
|
import { Button } from './Button';
|
|
|
|
export function ButtonInfiniteLoading({
|
|
onClick,
|
|
isLoading,
|
|
loadingChildren,
|
|
children,
|
|
...props
|
|
}: ButtonProps & { loadingChildren?: string }) {
|
|
const [localIsLoading, setLocalIsLoading] = useState<boolean>(false);
|
|
return (
|
|
<Button
|
|
isLoading={localIsLoading || isLoading}
|
|
onClick={(e) => {
|
|
setLocalIsLoading(true);
|
|
onClick?.(e);
|
|
}}
|
|
{...props}
|
|
>
|
|
{localIsLoading ? (loadingChildren ?? children) : children}
|
|
</Button>
|
|
);
|
|
}
|