mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-11 22:44:56 +02:00
remove forward ref
This commit is contained in:
parent
521bbbf1d6
commit
f14379a1c8
25 changed files with 2067 additions and 1779 deletions
|
@ -51,32 +51,32 @@ export interface ButtonProps
|
|||
loading?: boolean; // Add loading prop
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
(
|
||||
{
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
loading = false,
|
||||
...props
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
ref={ref}
|
||||
disabled={loading || props.disabled} // Disable button when loading
|
||||
{...props}
|
||||
>
|
||||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{props.children}
|
||||
</Comp>
|
||||
);
|
||||
const Button = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
loading = false,
|
||||
...props
|
||||
}: ButtonProps & {
|
||||
ref: React.RefObject<HTMLButtonElement>;
|
||||
}
|
||||
);
|
||||
) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
ref={ref}
|
||||
disabled={loading || props.disabled} // Disable button when loading
|
||||
{...props}
|
||||
>
|
||||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{props.children}
|
||||
</Comp>
|
||||
);
|
||||
};
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button, buttonVariants };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue